In my question type as returntype in c++ I was provided with an answer that gave me such a structure:
template <int N>
struct int_type {
using type = std::conditional_t<N <= 8, std::uint8_t,
std::conditional_t<N <= 16, std::uint16_t,
std::conditional_t<N <= 32, std::uint32_t,
std::conditional_t<N <= 64, std::uint64_t,
std::uintmax_t>>>>;
};
That seemed to do excactly what I need, how ever the practice looks different, since I can't compile it because of the following errors:
...Error: expected nested-name-specifier before 'type'
using type = std::conditional_t<N <= 8, std::uint8_t,
^
...Error: using-declaration for non-member at class scope
...Error: expected ';' before '=' token
using type = std::conditional_t<N <= 8, std::uint8_t,
^
...Error: expected unqualified-id before '=' token
I tried to google it, but none of the posts I found seem to adress this specific problems. Can anyone explain me what is wrong with this code? I'm pretty new to C++