C++11: custom variadic template literals: ЧЯДНТ?
От: alexanderfedin США http://alexander-fedin.pixels.com/
Дата: 09.12.19 18:50
Оценка:
Код выглядит так:
template <typename T, T... chars>
struct c_str
{
    constexpr c_str() noexcept {}
};

template <char... chars>
constexpr const c_str<char, chars...> operator "" _cs() noexcept
{
    return c_str<char, chars...>();
}

template <char... chars>
constexpr double operator "" _dbl() noexcept
{
    return 0.0;
}

int main()
{
    using d_t = decltype("2.7"_dbl);//error: no matching function for call to ‘operator""_dbl()’
    using s_t = decltype("abc"_cs);error: no matching function for call to ‘operator""_cs()’
    return 0;
}
Respectfully,
Alexander Fedin.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.