1

Topic: MSVC2015 constexpr and all this sample magic

Good afternoon. There is the certain purpose expressing in transfer of number at line at a stage of compilation STR (x) #x not to offer, handling with certain logic is necessary. The following minimum example perfectly fulfills on GCC/Clang, but does not gather in MSVC 2015 where like support constexpr is declared: #include <iostream> #define TAG 10000/* calculate number of digits */constexpr size_t num_digits (size_t x) {return x <10? 1: 1 + num_digits (x / 10);}/* storage for string data */template <char... args> struct metastring {const char data [sizeof... (args)] = {args...};};/* metastruct for string type */template <size_t size, size_t x, char... args> struct num_builder {typedef typename num_builder <size - 1, x / 10, ' 0 ' + (x % 10), args...>:: type type;};/* proceed last digit */template <size_t x, char... args> struct num_builder <1, x, args...> {typedef metastring <' 0 ' + x, args...> type;} ;/* metaclass fro conversation */template <size_t x> class __ builder {private:/* generate string type */typedef typename num_builder <num_digits (x), x, '\0 '>:: type type;/* string declaration */static constexpr type value {}; public:/* */static constexpr const char* get () {//error C2059: syntax error: ' inline function header '//error C2059: syntax error: "symbol"//error C2143: syntax error: missing '; ' before ' {'//error C2447: ' {': missing function header (old-style formal list?) return value.data;} };/* instantiate string */template <size_t x> constexpr typename __ builder <x>:: type __ builder <x>:: value;/* compile-time const for converted string */static constexpr const char* tag = __ builder <TAG>:: get ();//error C2131: expression did not evaluate to a constant//note: failure was caused by call of undefined function or one not declared ' constexpr '//note: see usage of ' __ builder <10000>:: get ' int main () {std:: cout <<"Hello world!" <<std:: endl; std:: cout <<"tag =" <<tag <<std:: endl; return 0;} who Can prompts, in what a problem and how it to solve? Or in MSVC all is not so good with support similar to "sample magic" (I can something it is not correct in it understand) and easier to refuse such decision generally? In advance I thank for answers.

2

Re: MSVC2015 constexpr and all this sample magic

If to transfer implementation get () after determination value like works:/* metaclass fro conversation */template <size_t x> class __ builder {private:/* generate string type */typedef typename num_builder <num_digits (x), x, '\0 '>:: type type;/* string declaration */static constexpr type value {}; public:/* */static constexpr const char* get ();};/* instantiate string */template <size_t x> constexpr typename __ builder <x>:: type __ builder <x>:: value; template <size_t x> constexpr const char * __ builder <x>:: get () {return (value.data);}/* compile-time const for converted string */static constexpr const char* tag = __ builder <TAG>:: get ();

3

Re: MSVC2015 constexpr and all this sample magic

Hello, VTT, you wrote: VTT> If to transfer implementation get () after determination value like works: At, the shaitan. I thank, earned and in the project!

4

Re: MSVC2015 constexpr and all this sample magic

Hello, Tujh, you wrote: T> There is the certain purpose expressing in transfer of number at line at a stage of compilation T> STR (x) #x T> not to offer, handling with certain logic is necessary. What only people the ugly code do not justify for fear of usage of simple macroes...

5

Re: MSVC2015 constexpr and all this sample magic

Hello, Vain, you wrote: V> what only people do not justify the ugly code for fear of usage of simple macroes... Yes it not fear, and is simple absence in the slightest degree critical thinking. Macroes-harms told. Means angrily. And why angrily - it is not necessary to think. That that above-stated  on templates still  angrily, nobody spoke. Therefore we have that that is had.

6

Re: MSVC2015 constexpr and all this sample magic

Hello, antropolog, you wrote: V>> what only people do not justify the ugly code for fear of usage of simple macroes... A> yes it not fear, and is simple absence in the slightest degree critical thinking. Macroes-harms told. Means angrily. And why angrily - it is not necessary to think. That that above-stated  on templates still  angrily, nobody spoke. Therefore we have that that is had. Than this code angrily? PS except double underline in a class title