This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2007 Timo Bingmann <[email protected]> | |
// Distributed under the Boost Software License, Version 1.0. | |
// (See http://www.boost.org/LICENSE_1_0.txt) | |
// | |
// Original link http://panthema.net/2007/0328-ZLibString.html | |
#include <string> | |
#include <stdexcept> | |
#include <iostream> | |
#include <iomanip> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) { | |
return static_cast<typename std::underlying_type<E>::type>(e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original: http://stackoverflow.com/a/12867287/1091536 | |
// Usage: | |
// To convert from given endian to host, use: | |
// host = endian(source, endian_of_source) | |
// To convert from host endian to given endian, use: | |
// output = endian(hostsource, endian_you_want_to_output) | |
enum class Endian: int { | |
Big = 1, Little = 0 | |
}; |