|
4219 | 4219 |
|
4220 | 4220 | \pnum |
4221 | 4221 | If \tcode{E2} is a \grammarterm{splice-expression}, |
4222 | | -then \tcode{E2} shall designate a member of the type of \tcode{E1}. |
| 4222 | +then let \tcode{T1} be the type of \tcode{E1}. |
| 4223 | +\tcode{E2} shall designate either |
| 4224 | +a member of the \tcode{T1} or |
| 4225 | +a direct base class relationship $(\tcode{T1}, \tcode{B})$. |
4223 | 4226 |
|
4224 | 4227 | \pnum |
4225 | 4228 | If \tcode{E2} designates a bit-field, \tcode{E1.E2} is a bit-field. The |
|
4249 | 4252 | \item Otherwise, if \tcode{E2} designates a non-static data member and the type of |
4250 | 4253 | \tcode{E1} is ``\cvqual{cq1 vq1} \tcode{X}'', and the type of \tcode{E2} |
4251 | 4254 | is ``\cvqual{cq2 vq2} \tcode{T}'', the expression designates the corresponding |
4252 | | -member subobject of the object designated by the first expression. If \tcode{E1} |
| 4255 | +member subobject of the object designated by \tcode{E1}. If \tcode{E1} |
4253 | 4256 | is an lvalue, then \tcode{E1.E2} is an lvalue; |
4254 | 4257 | otherwise \tcode{E1.E2} is an xvalue. |
4255 | 4258 | Let the notation \cvqual{vq12} stand for the ``union'' of |
|
4292 | 4295 | is \tcode{T}, the expression \tcode{E1.E2} is a prvalue of type \tcode{T} |
4293 | 4296 | whose value is the value of the enumerator. |
4294 | 4297 |
|
| 4298 | +\item If \tcode{E2} designates a direct base class relationship $(D, B)$ |
| 4299 | +and the type of \tcode{E1} is \cv{} \tcode{T}, |
| 4300 | +the expression designates the direct base class subobject of type $B$ |
| 4301 | +of the object designated by \tcode{E1}. |
| 4302 | +If \tcode{E1} is an lvalue, |
| 4303 | +then \tcode{E1.E2} is an lvalue; |
| 4304 | +otherwise, \tcode{E1.E2} is an xvalue. |
| 4305 | +The type of \tcode{E1.E2} is ``\cv{} \tcode{$B$}''. |
| 4306 | +\begin{note} |
| 4307 | +This can only occur in an expression of the form \tcode{e1.[:e2:]}. |
| 4308 | +\end{note} |
| 4309 | +\begin{example} |
| 4310 | +\begin{codeblock} |
| 4311 | +struct B { |
| 4312 | + int b; |
| 4313 | +}; |
| 4314 | +struct C : B { |
| 4315 | + int get() const { return b; } |
| 4316 | +}; |
| 4317 | +struct D : B, C { }; |
| 4318 | + |
| 4319 | +constexpr int f() { |
| 4320 | + D d = {1, {}}; |
| 4321 | + |
| 4322 | + // \tcode{b} unambiguously refers to the direct base class of type \tcode{B}, |
| 4323 | + // not the indirect base class of type \tcode{B} |
| 4324 | + B& b = d.[: std::meta::bases_of(^^D, std::meta::access_context::current())[0] :]; |
| 4325 | + b.b += 10; |
| 4326 | + return 10 * b.b + d.get(); |
| 4327 | +} |
| 4328 | +static_assert(f() == 110); |
| 4329 | +\end{codeblock} |
| 4330 | +\end{example} |
| 4331 | + |
4295 | 4332 | \item Otherwise, the program is ill-formed. |
4296 | 4333 | \end{itemize} |
4297 | 4334 |
|
|
0 commit comments