Questions tagged [injected-class-name]

13 questions
14
votes
1 answer

Why does having a declaration of a private base class render a type name inaccessible?

I am surprised that in the following example declaring Middle's base class private makes that name unavailable as a type in a subsequent derivation. class Base { public: Base(Base const& b) : i(b.i) {} int i; }; class Middle : private Base { …
John Yates
  • 1,027
  • 1
  • 7
  • 18
6
votes
2 answers

Can an injected class name be used as a type name in a friend declaration?

Consider this code: template class Singleton { }; class Logger : public Singleton { friend class Singleton; }; It compiles in gcc and clang, but is it valid? [temp.local].1 says: When it is used with a…
6
votes
1 answer

Why injected-class-name is sometimes not treated as a template name in a class template?

Source In the following cases, the injected-class-name is treated as a template-name of the class template itself: it is followed by < it is used as a template argument that corresponds to a template template parameter it is the final identifier…
ledonter
  • 1,269
  • 9
  • 27
4
votes
2 answers

What happens when Injected-Class-Name occurs? (C++)

According to https://en.cppreference.com/w/cpp/language/injected-class-name In a class scope, the name of the current class is treated as if it were a public member name; this is called injected-class-name. The point of declaration of the name…
csguy
  • 1,354
  • 2
  • 17
  • 37
4
votes
1 answer

Do I need to specify typename in the return type of member function if the function is defined inside the body of the class?

Consider the example below: template class SomeClass { // rest of the definition ... SomeClass& function1() { // ... return *this; } SomeClass& function2() { // ... return *this; …
user5818995
2
votes
4 answers

Interchanging class & struct keyword in C++

I was reading about one of the strange C++ feature called Injected class name here. I tried following simple program #include class test { int s{3}; public: int get_s() { return s; } }; int main() { class test::test…
Destructor
  • 14,123
  • 11
  • 61
  • 126
1
vote
1 answer

what is difference between Node * next and Node * next?

I was writing implementation of Linked List in the bellow code we have Node * next; and Node * next; I think both are doing same as pointing to object of Node class or there is difference between them. template class Node{ T…
1
vote
1 answer

Strange styling through injected stylesheets with class "logo-icon" in Chrome

My project is built on Angular 9+. Everything used to work correctly. But today (07.08.2020) chrome(Version 84.0.4147.105 (Official Build) (64-bit)) added some injected stylesheet. My logo-icon got some styles from chrome. But it works correctly…
Anarbek
  • 11
  • 1
1
vote
2 answers

Private inheritance visibility/access in C++

Why does an interface have a special visibility in a method due to a private inheritance? Note that a global specifier :: is required in my derived class. I don't understand why a method inherits some kind of visibility due to private inheritance.…
dmayola
  • 502
  • 5
  • 16
1
vote
2 answers

Difference between adding and omitting template parameter for class name inside constructor

I want to know if there is essentially a difference between: template class foo{ foo(){}; }; template class foo{ foo(){}; }; Both seem to work, but I don't understand the difference between the two. The first one…
AspiringMat
  • 2,161
  • 2
  • 21
  • 33
1
vote
1 answer

Lookup of base class name after inheriting constructor

Consider the following code: struct base {}; struct derived : public base { using base::base; base foo() const; // how does name lookup on 'base' here work? }; Intuitively, it's clear that this code is valid, and it does compile (tested…
0
votes
1 answer

Curious Mixin with variadic constructor

I have a code snipped including a variadic mixin crtp of some sorts and a few related questions. Do I understand correctly that in the following code, the second constructor is merely passing copies of instances of those classes which were used to…
CD86
  • 979
  • 10
  • 27
0
votes
0 answers

Little strange issue on a simple js

I've got a little problem on a simple script It applies a className only one time on two. here is my code. Thanks by advance to all community and, please forgive the poor english of a french guy :-) !
AlexB
  • 1