I tried invoking a method directly on the result of the user-defined literal, but my results varied depending on the compiler.
#include <string>
std::string operator ""_test(unsigned long long value)
{
    return std::to_string(value);
}
int main()
{
    1000_test.size();   // 1) NOK on Clang/GCC, OK on MSVC
    (1000_test).size(); // 2) OK everywhere
    1000_test + "a";    // 3) OK overywhere
}
Case 1) seems odd, since the compilers seem to disallow defining _test.size user-defined literal.
So which compiler is correct here for the 1) case? What does the standard say?
Aucun commentaire:
Enregistrer un commentaire