Skip to content

Commit

Permalink
Ifdef is_trivially_copyable<T> behind gcc >= 5 guard
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-j-h committed Feb 8, 2016
1 parent e220d38 commit 9ee315e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/engine/object_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ using BinaryFromBase64 = boost::archive::iterators::transform_width<

template <typename T> std::string encodeBase64(const T &x)
{
// static_assert(std::is_trivially_copyable<T>::value, "requires a trivially copyable type");
#if not defined __GNUC__ or __GNUC__ > 4
static_assert(std::is_trivially_copyable<T>::value, "requires a trivially copyable type");
#endif

std::vector<unsigned char> bytes{reinterpret_cast<const char *>(&x),
reinterpret_cast<const char *>(&x) + sizeof(T)};
Expand All @@ -65,7 +67,9 @@ template <typename T> std::string encodeBase64(const T &x)

template <typename T> T decodeBase64(std::string encoded)
{
// static_assert(std::is_trivially_copyable<T>::value, "requires a trivially copyable type");
#if not defined __GNUC__ or __GNUC__ > 4
static_assert(std::is_trivially_copyable<T>::value, "requires a trivially copyable type");
#endif

std::replace(begin(encoded), end(encoded), '-', '+');
std::replace(begin(encoded), end(encoded), '_', '/');
Expand Down

0 comments on commit 9ee315e

Please sign in to comment.