fix tuple_element: support SFINAE-friendly

This commit is contained in:
bolero-MURAKAMI 2014-05-29 00:25:37 +09:00
parent f42e92b448
commit c15de6136b
64 changed files with 984 additions and 113 deletions

View file

@ -25,12 +25,18 @@ namespace sprout {
public:
typedef T type;
public:
static SPROUT_CONSTEXPR std::size_t size() {
static SPROUT_CONSTEXPR std::size_t
size() {
return sizeof(type);
}
static SPROUT_CONSTEXPR unsigned char get_byte(type const& t, std::size_t) {
static SPROUT_CONSTEXPR unsigned char
get_byte(type const& t, std::size_t) {
return static_cast<unsigned char>(t);
}
static SPROUT_CXX14_CONSTEXPR void
set_byte(type& t, std::size_t, unsigned char value) {
t = static_cast<type>(value);
}
};
template<typename T>
class default_big_endian_traits<
@ -40,15 +46,22 @@ namespace sprout {
public:
typedef T type;
public:
static SPROUT_CONSTEXPR std::size_t size() {
static SPROUT_CONSTEXPR std::size_t
size() {
return sizeof(type);
}
static SPROUT_CONSTEXPR unsigned char get_byte(type const& t, std::size_t i) {
static SPROUT_CONSTEXPR unsigned char
get_byte(type const& t, std::size_t i) {
return static_cast<unsigned char>(
(t & (UCHAR_MAX << CHAR_BIT * ((size() - 1) - i)))
>> CHAR_BIT * ((size() - 1) - i)
);
}
static SPROUT_CXX14_CONSTEXPR void
set_byte(type& t, std::size_t i, unsigned char value) {
t &= ~(UCHAR_MAX << CHAR_BIT * ((size() - 1) - i));
t |= (value << CHAR_BIT * ((size() - 1) - i));
}
};
template<typename T, typename Enable = void>
@ -67,6 +80,10 @@ namespace sprout {
static SPROUT_CONSTEXPR unsigned char get_byte(type const& t, std::size_t) {
return static_cast<unsigned char>(t);
}
static SPROUT_CXX14_CONSTEXPR void
set_byte(type& t, std::size_t, unsigned char value) {
t = static_cast<type>(value);
}
};
template<typename T>
class default_little_endian_traits<
@ -85,6 +102,11 @@ namespace sprout {
>> CHAR_BIT * i
);
}
static SPROUT_CXX14_CONSTEXPR void
set_byte(type& t, std::size_t i, unsigned char value) {
t &= ~(UCHAR_MAX << CHAR_BIT * i);
t |= (value << CHAR_BIT * i);
}
};
} // namespace detail