c++ - Custom literal works with long double but not double, and with pass by value but not pass by reference -


I'm experimenting with C ++ custom literals. I find it strange that when I change type from long double type to double , or when trying to pass from context, then working the normal function below First of all I thought that it had to be done with the use of constexpr but it does not seem that these two works are right because it is not on the code. Operator "" , and constexpr to remove from operator "" not error Removes.

Is it well thought out that the specifics in the design of language, or just that the specifics that can not deal with my compiler (GCC 4.8.2)? // conversion function, both long double and double / double, and without reference with or without Constexpr long double to_deg (const long double and degree) {return degree * M_PI / 180.0 ; } // long pass with double passwords, literally and with value, // work fine Constexpr long double operator "" _deg (long double degree) {return degree * M_PI / 180.0; } // Supports custom literal, "invalid argument list" with double types. // Error Constexpr double operator "" _deg (double degree) {return degree * M_PI / 180.0; } // Returns the custom verbally, "invalid argument list" with reference from near. // Error does not remove delete error Constexpr long double operator "" _deg (constant long double and degree) {return degree * M_PI / 180.0; }

C ++ standard, section § 13.5.8 (user-defined litrils) , Lists all valid types:

The announcement of a literal operator will be a parameter-declaration-clause equal to one of the following:

  • const char
  • Longer integer
  • long double
  • four
  • wchar_t
  • char16_t
  • Char32_t
  • const char *, std :: size_t
  • const wchar_t *, std :: size_t
  • const char16_t *, std :: size_t
  • const char32_t *, std :: size_t

    neither double or double & amp; , Constant Long Double & amp; are listed here: so they do not have permission.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -