Skip to content

Commit

Permalink
Simplified std::byte for C++03
Browse files Browse the repository at this point in the history
  • Loading branch information
jwellbelove committed Feb 16, 2022
1 parent b472563 commit 1aead2e
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions include/etl/byte.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,10 @@ namespace etl
public:

// Friend functions
friend etl::byte operator |(etl::byte lhs, etl::byte rhs);
friend etl::byte operator &(etl::byte lhs, etl::byte rhs);
friend etl::byte operator ^(etl::byte lhs, etl::byte rhs);

template <typename TInteger>
friend
typename etl::enable_if<etl::is_integral<TInteger>::value, etl::byte>::type
operator <<(etl::byte b, TInteger shift);

template <typename TInteger>
friend
typename etl::enable_if<etl::is_integral<TInteger>::value, etl::byte>::type
operator >>(etl::byte b, TInteger shift);

template <typename TInteger>
friend
typename etl::enable_if<etl::is_integral<TInteger>::value, TInteger>::type
to_integer(etl::byte b);
typename etl::enable_if<etl::is_integral<TInteger>::value, TInteger>::type
to_integer(etl::byte b);

friend bool operator ==(etl::byte lhs, etl::byte rhs);

Expand Down Expand Up @@ -214,7 +200,7 @@ namespace etl
typename etl::enable_if<etl::is_integral<TInteger>::value, etl::byte>::type
operator <<(etl::byte b, TInteger shift)
{
return etl::byte(static_cast<unsigned int>(b) << shift);
return etl::byte(to_integer<unsigned int>(b) << shift);
}

//*************************************************************************
Expand All @@ -224,7 +210,7 @@ namespace etl
typename etl::enable_if<etl::is_integral<TInteger>::value, etl::byte>::type
operator >>(etl::byte b, TInteger shift)
{
return etl::byte(static_cast<unsigned int>(b) >> shift);
return etl::byte(to_integer<unsigned int>(b) >> shift);
}

//*************************************************************************
Expand Down Expand Up @@ -256,23 +242,23 @@ namespace etl
//*************************************************************************
etl::byte operator |(etl::byte lhs, etl::byte rhs)
{
return etl::byte(static_cast<unsigned int>(lhs) | static_cast<unsigned int>(rhs));
return etl::byte(to_integer<unsigned int>(lhs) | to_integer<unsigned int>(rhs));
}

//*************************************************************************
/// And.
//*************************************************************************
etl::byte operator &(etl::byte lhs, etl::byte rhs)
{
return etl::byte(static_cast<unsigned int>(lhs) & static_cast<unsigned int>(rhs));
return etl::byte(to_integer<unsigned int>(lhs) & to_integer<unsigned int>(rhs));
}

//*************************************************************************
/// Exclusive Or.
//*************************************************************************
etl::byte operator ^(etl::byte lhs, etl::byte rhs)
{
return etl::byte(static_cast<unsigned int>(lhs) ^ static_cast<unsigned int>(rhs));
return etl::byte(to_integer<unsigned int>(lhs) ^ to_integer<unsigned int>(rhs));
}

//*************************************************************************
Expand Down

0 comments on commit 1aead2e

Please sign in to comment.