6

The following does not work on G++ 4.8.1 nor on 4.9:

constexpr double operator"" _sig (double sig)                               
{                                                                           
    return sig * 2.0;                                                      
}

prog.cpp:4:49: error: ‘constexpr double operator"" _sig(double)’ has invalid argument list constexpr double operator"" _sig (double sig)

Oddly enough, the following does work:

constexpr long double operator"" _sig (long double sig)                               
{                                                                           
    return sig * 2.0;                                                      
}   

Why??

quant
  • 21,507
  • 32
  • 115
  • 211
  • @Mgetz hmm, maybe, but I've tried changing `sig` to something else, and using different names for the parameter as the literal name, still the same problem. I've even changed the type to `float`! – quant May 02 '14 at 13:58
  • @PhilippLenk how do I make a user-defined literal for a signed integer then? – quant May 02 '14 at 14:02
  • What does that have to do with this question? – Lightness Races in Orbit May 02 '14 at 14:05
  • I am not really sure, but i believe if it returns a used defined type you could overload unary minus on that. I dont think its possible with built in types(i could very well be wrong) – Philipp Lenk May 02 '14 at 14:07
  • @PhilippLenk I asked a follow-up: http://stackoverflow.com/questions/23430296/how-do-i-create-a-user-defined-literal-for-a-signed-integer-type – quant May 02 '14 at 14:17

0 Answers0