Implement most of P1612R1: Relocate endian. Moves the std::endian functionality from 'type-traits' to 'bit'. No other change. The reason that this is 'partial' is that P1621 also recommends a feature-test macro, but I don't have the value for that one yet. In a month or so, I'll add that
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366776 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/bit b/include/bit
index 1c0e8ad..8800b22 100644
--- a/include/bit
+++ b/include/bit
@@ -42,6 +42,13 @@
template<class T>
constexpr int popcount(T x) noexcept; // C++20
+ // 20.15.9, endian
+ enum class endian {
+ little = see below, // C++20
+ big = see below, // C++20
+ native = see below // C++20
+};
+
} // namespace std
*/
@@ -456,6 +463,20 @@
return __t == 0 ? 0 : __bit_log2(__t) + 1;
}
+
+enum class endian
+{
+ little = 0xDEAD,
+ big = 0xFACE,
+#if defined(_LIBCPP_LITTLE_ENDIAN)
+ native = little
+#elif defined(_LIBCPP_BIG_ENDIAN)
+ native = big
+#else
+ native = 0xCAFE
+#endif
+};
+
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/include/type_traits b/include/type_traits
index 5ccafec..e0b6f13 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -3985,21 +3985,6 @@
#endif
-#if _LIBCPP_STD_VER > 17
-enum class endian
-{
- little = 0xDEAD,
- big = 0xFACE,
-#if defined(_LIBCPP_LITTLE_ENDIAN)
- native = little
-#elif defined(_LIBCPP_BIG_ENDIAN)
- native = big
-#else
- native = 0xCAFE
-#endif
-};
-#endif
-
#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
diff --git a/test/std/utilities/meta/meta.type.synop/endian.pass.cpp b/test/std/numerics/bit/bit.endian/endian.pass.cpp
similarity index 98%
rename from test/std/utilities/meta/meta.type.synop/endian.pass.cpp
rename to test/std/numerics/bit/bit.endian/endian.pass.cpp
index 52924b3..d680faf 100644
--- a/test/std/utilities/meta/meta.type.synop/endian.pass.cpp
+++ b/test/std/numerics/bit/bit.endian/endian.pass.cpp
@@ -9,8 +9,9 @@
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// enum class endian;
+// <bit>
-#include <type_traits>
+#include <bit>
#include <cstring>
#include <cassert>
#include <cstdint>