jeudi 27 août 2015

Check whether or not a user-defined literal has already been defined

C++11 has introduced user-defined literals. So, we can have cool things like

constexpr std::complex<double> operator""i(unsigned long long d) {
    return std::complex<double>{0., static_cast<double>(d)};
}

constexpr std::complex<double> operator""i(long double d) {
    return std::complex<double>{0., static_cast<double>(d)};
}

What happens if these operators were already defined? Is there any possibility to check this and define the operators above only if they don't exist?

Aucun commentaire:

Enregistrer un commentaire