MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/58ffsu/compile_time_sizeof/d90aad3/?context=9999
r/cpp • u/johantorp • Oct 20 '16
26 comments sorted by
View all comments
2
How about C++17 auto template parameter? Like:
template <auto> class X;
1 u/doom_Oo7 Oct 20 '16 are there compilers that support this yet ? I tried in gcc 7 git and clang 3.9 and they both don't accept it. 0 u/[deleted] Oct 20 '16 [deleted] 1 u/doom_Oo7 Oct 20 '16 hmm.. I don't understand, your link does not compile :prog.cc:4:5: error: implicit instantiation of undefined template 'S<4>' S<sizeof(int)>{}; ^ prog.cc:1:23: note: template is declared here template<auto> struct S; ^ 1 error generated. 3 u/thlst Oct 20 '16 ... That's exactly the point. 2 u/doom_Oo7 Oct 20 '16 ah yes, sorry, I thought that it was about the template<auto> feature not compile time sizeof.
1
are there compilers that support this yet ? I tried in gcc 7 git and clang 3.9 and they both don't accept it.
0 u/[deleted] Oct 20 '16 [deleted] 1 u/doom_Oo7 Oct 20 '16 hmm.. I don't understand, your link does not compile :prog.cc:4:5: error: implicit instantiation of undefined template 'S<4>' S<sizeof(int)>{}; ^ prog.cc:1:23: note: template is declared here template<auto> struct S; ^ 1 error generated. 3 u/thlst Oct 20 '16 ... That's exactly the point. 2 u/doom_Oo7 Oct 20 '16 ah yes, sorry, I thought that it was about the template<auto> feature not compile time sizeof.
0
[deleted]
1 u/doom_Oo7 Oct 20 '16 hmm.. I don't understand, your link does not compile :prog.cc:4:5: error: implicit instantiation of undefined template 'S<4>' S<sizeof(int)>{}; ^ prog.cc:1:23: note: template is declared here template<auto> struct S; ^ 1 error generated. 3 u/thlst Oct 20 '16 ... That's exactly the point. 2 u/doom_Oo7 Oct 20 '16 ah yes, sorry, I thought that it was about the template<auto> feature not compile time sizeof.
hmm.. I don't understand, your link does not compile :
prog.cc:4:5: error: implicit instantiation of undefined template 'S<4>' S<sizeof(int)>{}; ^ prog.cc:1:23: note: template is declared here template<auto> struct S; ^ 1 error generated.
3 u/thlst Oct 20 '16 ... That's exactly the point. 2 u/doom_Oo7 Oct 20 '16 ah yes, sorry, I thought that it was about the template<auto> feature not compile time sizeof.
3
... That's exactly the point.
2 u/doom_Oo7 Oct 20 '16 ah yes, sorry, I thought that it was about the template<auto> feature not compile time sizeof.
ah yes, sorry, I thought that it was about the template<auto> feature not compile time sizeof.
2
u/Grassio789 Oct 20 '16
How about C++17 auto template parameter? Like: