samedi 28 décembre 2019

Back-porting chrono string literal operators

I want to allow the use of string literal operators introduced with c++14 with c++11. I wrote something like that:

namespace MYNAMESPACE {
#if __cplusplus < 201402L
constexpr std::chrono::seconds operator""s(unsigned long long int v) {
return std::chrono::seconds(v);
}
#else
using namespace std::literals::chrono_literals;
#endif
}

Is it possible? If I well understood the ADL rules, this code shouldn't work because the basic types should belong to the global namespace, so the lookup should be performed in the global namespace instead of using my own namespace.

Aucun commentaire:

Enregistrer un commentaire