Daha iyi bir kelime olmaması nedeniyle "SFINAE" ile cbor formatı için beden kodunu uygulamaya çalışıyorum. Ancak, size_code<3>
gibi, çalışmaz, 0x1b
olarak değerlendirir. Sorun nedir? kodunuz çalışmaya olmamalıdır böylecedeğişken şablon "SFINAE" çalışmıyor
template <::std::size_t N,
typename = ::std::enable_if_t<N <= 0x17>
>
constexpr ::std::uint8_t const size_code = N;
template <::std::size_t N,
typename = ::std::enable_if_t<(N > 0x17) &&
(N <= ::std::numeric_limits<::std::uint8_t>::max())
>
>
constexpr ::std::uint8_t const size_code = 0x18;
template <::std::size_t N,
typename = ::std::enable_if_t<
(N > ::std::numeric_limits<::std::uint8_t>::max()) &&
(N <= ::std::numeric_limits<::std::uint16_t>::max())
>
>
constexpr ::std::uint8_t const size_code = 0x19;
template <::std::size_t N,
typename = ::std::enable_if_t<
(N > ::std::numeric_limits<::std::uint16_t>::max()) &&
(N <= ::std::numeric_limits<::std::uint32_t>::max())
>
>
constexpr ::std::uint8_t const size_code = 0x1a;
template <::std::size_t N,
typename = ::std::enable_if_t<
(N > ::std::numeric_limits<::std::uint32_t>::max()) &&
(N <= ::std::numeric_limits<::std::uint64_t>::max())
>
>
constexpr ::std::uint8_t const size_code = 0x1b;
O şey değerlendirmek gerekir. Bu kod, 'size_code' değerini yeniden tanımlamak için kötü biçimlendirilmiştir. –
Bunun için bir "constexpr" işlevi yazmanız daha iyi olurdu. – TartanLlama
@ T.C. gcc tuhaflığı, ama clang bunu tanır. – user1095108