I'm wondering why I can't write code like this:
constexpr double radius = 27_km.to_miles(); // _km returns Distance instance
// which has to_miles()
Both GCC 4.8.1 and Clang 3.4 complain that they couldn't find literal operator operator"" _km.to_miles
unless I wrap 27_km
in parentheses:
constexpr double radius = (27_km).to_miles(); // fine
By my reading of section 2.14.8 of the standard, a UDL suffix can't contain a period, so why are the compilers parsing the code like this? Are they correct or is it a bug?
EDIT: You can see a full example (with different UDL and method names) here: http://ideone.com/rvB1pk