X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5d99dbf06a14904944f5593c63705934bdfdcfb7..c279db4240a3a3c30f069ab9dea8055cf94280da:/endian.h diff --git a/endian.h b/endian.h index 7385406..feb3bbd 100644 --- a/endian.h +++ b/endian.h @@ -20,22 +20,26 @@ inline int64_t hton(int64_t t) { return (int64_t)hton((uint64_t)t); } template inline T ntoh(T t) { return hton(t); } -template inline tuple::type...> +template +inline tuple::type...> tuple_hton_imp(tuple && t, tuple_indices) { - return tuple::type...>(hton(get(t))...); + return tuple< + typename std::remove_reference::type... + >(hton(std::get(t))...); } -template inline tuple::type...> +template +inline tuple::type...> hton(tuple && t) { - using Indices = typename make_tuple_indices::type; - return tuple_hton_imp(forward>(t), Indices()); + return tuple_hton_imp(std::forward>(t), TUPLE_INDICES(Args)); } -#define ENDIAN_SWAPPABLE(_c_) \ -inline _c_ hton(_c_ && t) { \ - _c_ result; \ - result._tuple_() = hton(t._tuple_()); \ - return result; \ +template inline typename +enable_if::value, T>::type +hton(T && t) { + T result; + result._tuple_() = hton(t._tuple_()); + return result; } #endif