5 #ifndef VCCC_CORE_BYTE_HPP
6 #define VCCC_CORE_BYTE_HPP
10 #include <initializer_list>
11 #include <type_traits>
21 #if __cplusplus < 201703L
24 struct byte_ctor_tag {};
31 constexpr explicit
byte(
std::initializer_list<
unsigned char> il)
32 : value_(*il.
begin()) {
33 assert(((
void)
"Size must be one", il.size() == 1));
37 constexpr
explicit byte(
unsigned char c, detail::byte_ctor_tag) noexcept : value_(c) {}
39 constexpr
explicit operator unsigned char() const noexcept {
47 template<
typename IntegerType>
50 return IntegerType(b.operator
unsigned char());
53 template <
class IntegerType>
55 operator<<(
byte b, IntegerType shift) noexcept {
57 static_cast<unsigned char>(
58 static_cast<unsigned int>(b.operator
unsigned char()) << shift
60 detail::byte_ctor_tag{}
64 template <
class IntegerType>
68 static_cast<unsigned char>(
69 static_cast<unsigned int>(b.operator
unsigned char()) >> shift
71 detail::byte_ctor_tag{}
75 template <
class IntegerType>
78 return b = b << shift;
81 template <
class IntegerType>
84 return b = b >> shift;
89 static_cast<unsigned char>(
90 static_cast<unsigned int>(l.operator
unsigned char()) |
static_cast<unsigned int>(r.operator
unsigned char())
92 detail::byte_ctor_tag{}
98 static_cast<unsigned char>(
99 static_cast<unsigned int>(l.operator
unsigned char()) &
static_cast<unsigned int>(r.operator
unsigned char())
101 detail::byte_ctor_tag{}
107 static_cast<unsigned char>(
108 static_cast<unsigned int>(l.operator
unsigned char()) ^
static_cast<unsigned int>(r.operator
unsigned char())
110 detail::byte_ctor_tag{}
115 static_cast<unsigned char>(
116 ~
static_cast<unsigned int>(b.operator
unsigned char())
118 detail::byte_ctor_tag{}
134 using byte = std::byte;
136 template<
typename IntegerType>
139 return IntegerType(b);
constexpr byte(unsigned char c, detail::byte_ctor_tag) noexcept
Definition: byte.hpp:37
constexpr std::enable_if_t< std::is_integral< IntegerType >::value, byte & > operator<<=(byte &b, IntegerType shift) noexcept
Definition: byte.hpp:77
constexpr byte & operator&=(byte &l, byte r) noexcept
Definition: byte.hpp:126
constexpr std::enable_if_t< std::is_integral< IntegerType >::value, byte > operator>>(byte b, IntegerType shift) noexcept
Definition: byte.hpp:66
constexpr byte operator^(byte l, byte r) noexcept
Definition: byte.hpp:105
constexpr byte operator~(byte b) noexcept
Definition: byte.hpp:113
constexpr std::enable_if_t< std::is_integral< IntegerType >::value, IntegerType > to_integer(byte b) noexcept
Definition: byte.hpp:49
constexpr std::enable_if_t< std::is_integral< IntegerType >::value, byte & > operator>>=(byte &b, IntegerType shift) noexcept
Definition: byte.hpp:83
constexpr byte & operator|=(byte &l, byte r) noexcept
Definition: byte.hpp:122
constexpr byte operator&(byte l, byte r) noexcept
Definition: byte.hpp:96
constexpr byte & operator^=(byte &l, byte r) noexcept
Definition: byte.hpp:130
constexpr byte operator|(byte l, byte r) noexcept
Definition: byte.hpp:87
std::ostream & operator<<(std::ostream &os, const MatrixBase< E > &mat_expr)
Definition: matrix_ostream.hpp:17
constexpr VCCC_INLINE_OR_STATIC detail::begin_niebloid begin
returns an iterator to the beginning of a range
Definition: begin.hpp:116
Definition: matrix.hpp:495
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35