I have a CRTP template class:
template <typename S> class Base { public: constexpr static S NOT_SET{0}; }; struct Derived : public Base<Derived> { };
Clang (5.0.0) does not accept this:
5 : <source>:5:24: error: constexpr variable cannot have non-literal type 'const Derived' constexpr static S NOT_SET{0}; ^ 8 : <source>:8:25: note: in instantiation of template class 'Base<Derived>' requested here struct Derived : public Base<Derived> ^ 5 : <source>:5:24: note: incomplete type 'const Derived' is not a literal type constexpr static S NOT_SET{0}; ^ 8 : <source>:8:8: note: definition of 'Derived' is not complete until the closing '}' struct Derived : public Base<Derived> ^ 1 error generated. Compiler exited with result code 1
But gcc (tested on 4.9.2 and 6.2) accepts it just fine.
How to do this in clang?
Derived Base, . , , . ., } ( , , , -)., ( ):
Derived
Base
}
( ) } .- , , noexcept-specificiers ( )..
, clang , .
, . , (, ) constexpr , constexpr , ( ).
Source: https://habr.com/ru/post/1687711/More articles:Firebase Firestore - альтернатива OR запроса - swiftHow do you define buildConfigField in Gradle Java-library Project build script - javaq - recursion with / - kdberror: no member named 'rank_' in 'EndIndex' - c ++Как запросить Cloud Firestore для несуществующих ключей документов - firebaseFirestore select where not null - javascriptJava 8 thread grouping operation - javagetting output from class resolution - haskellCompilation in Java 7 - a method that uses Java 8 types - javaWKWebView fullscreen instead of frame? - iosAll Articles