Author: | erikc |
---|---|
Mode: | c++ |
Date: | Mon, 17 Jan 2011 21:15:55 |
enum class endian_t = { little, big }; static constexpr endian_t le = endian_t::little; static constexpr endian_t be = endian_t::big; static constexpr endian_t ne = *&((const char&) 1) ? le : be; template <endian_t from, typename T> T swap_from(const T& t) { if (from == ne) return t; return swap_bytes(t); }