Consider following code snippet with C++20 using-enum-declaration: namespace A { enum A {}; }; using namespace A; using enum A; gcc-trunk rejects it with: <source>:4:12: error: reference to ‘A’ is ambiguous 4 | using enum A; | ^ <source>:1:20: note: candidates are: ‘enum A::A’ 1 | namespace A { enum A {}; }; | ^ ..
Category : using-declaration
We know that a ‘using declaration’ for a namespace’s member name in a scope where another entity is defined there with the same name, causes a compile time error: "symbol x is already defined". The error is detected at the point the ‘using declaration’ appears not at use point like a ‘using directive’. A using ..
According to the C++ 17 Standard (10.3.3 The using declaration) 1 Each using-declarator in a using-declaration98 introduces a set of declarations into the declarative region in which the using-declaration appears. and 10 A using-declaration is a declaration and can therefore be used repeatedly where (and only where) multiple declarations are allowed. and (The C++ 17 ..
According to cppreference, both gcc and msvc have completed the implementation of C++20 feature using enum, which means we can using-declaration with an enum: struct A { enum e { /* … */ }; }; struct S { using enum A::e; }; But when I apply it to the templates: template <class T> struct S ..
With ‘using declarations’ I can introduce a base class member into definition of my class: class Base { public: void baseMemberFn(); /* … */ }; class Derived : private Base { public: using Base::baseMemberFn; }; However, in my case, I want to only ‘use’ one specific overload of the member from the base class. Is ..
After reading the accepted answer from this question, I thought I understood why the program failed, since the using declaration does not actually declare the entity i in the region. However names introduced by a using declaration can be used just like any other name and acts like a declaration. With GCC, this fails #include ..
I stumbled upon a question of the using-declared inheriting constructor yesterday. And after carefully reading the answer as well as the linked standard draft N3337, I found there might be some inconsistency (or at least my misunderstanding) when the direct base class also uses using to inherit constructors from the virtual base. Here is an ..
Recent Comments