Simplifications and clean-ups
[invirt/third/libt4.git] / endian.h
index 7385406..f34d371 100644 (file)
--- a/endian.h
+++ b/endian.h
@@ -27,15 +27,15 @@ tuple_hton_imp(tuple<Args...> && t, tuple_indices<Indices...>) {
 
 template <class... Args> inline tuple<typename remove_reference<Args>::type...>
 hton(tuple<Args...> && t) {
-    using Indices = typename make_tuple_indices<sizeof...(Args)>::type;
-    return tuple_hton_imp(forward<tuple<Args...>>(t), Indices());
+    return tuple_hton_imp(forward<tuple<Args...>>(t), TUPLE_INDICES(Args));
 }
 
-#define ENDIAN_SWAPPABLE(_c_) \
-inline _c_ hton(_c_ && t) { \
-    _c_ result; \
-    result._tuple_() = hton(t._tuple_()); \
-    return result; \
+template <class T> inline typename
+enable_if<is_tuple_convertible<T>::value, T>::type
+hton(T && t) {
+    T result;
+    result._tuple_() = hton(t._tuple_());
+    return result;
 }
 
 #endif