X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5d99dbf06a14904944f5593c63705934bdfdcfb7..02967a43024ce81912cd1ec96a800397457f8066:/endian.h diff --git a/endian.h b/endian.h index 7385406..7c78bbc 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...> -tuple_hton_imp(tuple && t, tuple_indices) { - return tuple::type...>(hton(get(t))...); +template +inline tuple::type...> +tuple_hton_imp(tuple && t, std::index_sequence) { + 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), std::index_sequence_for{}); } -#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