Ref:
injected class name
[c++11][NOTE][ORIGINAL] const references in c++ templates
[so] Inherit from const type passed as template parameter
Valid since while using typedef, i.e template<typename>injected class name
[c++11][NOTE][ORIGINAL] const references in c++ templates
[so] Inherit from const type passed as template parameter
is really typedef, if the type alias is used as a type name, the c.v will be dropped.
[class.name]/5:
If a typedef-name that names a cv-qualified class type is used where a class-name is required, the cv-qualifiers are ignored.
struct base {
};
template<typename T>
struct inherit : T {
using T::T;
};
int main() {
inherit<base const>{};
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.