auto as nontype template parameter fails to compile
-
template<auto Value> struct C { static constexpr auto value = Value; }; int main() { auto c = C<42>{}; }
#1 with x86-64 gcc 8.2
<source>:2:15: error: 'auto' parameter not permitted in this contexttemplate<auto Value> struct C {
any ideas why?
-
Du musst die C++1z Features mit -std=c++1z unterstützen, dann geht´s mit gcc8.2.
Godbolt Compiler Explorer
-
Bzw. einfach nur -std=c++17
-
ich bin davon ausgegangen, dass gcc-9.2 nativ C++17 unterstützt
-
@sewing sagte in auto as nontype template parameter fails to compile:
ich bin davon ausgegangen, dass gcc-9.2 nativ C++17 unterstützt
Tut es auch nur nicht in der default Einstellung. Das hat was mit abwärstkompatibilität zu tun.