From: Jonathan Wakely Date: Thu, 25 Jul 2019 20:30:25 +0000 (+0100) Subject: Relocate std::endian from to X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=45c7215c1e17de75ea1abce59c3927f3f83d4b24;p=gcc.git Relocate std::endian from to This change to an early C++2a feature was just approved (P1612R1). * include/std/bit (endian): Move definition here as per P1612R1. * include/std/type_traits (endian): Remove definition from here. * testsuite/20_util/endian/1.cc: Rename to ... * testsuite/26_numerics/endian/1.cc: ... here. Adjust header. From-SVN: r273816 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a92e7a7783b..21f352a10b6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2019-07-25 Jonathan Wakely + + * include/std/bit (endian): Move definition here as per P1612R1. + * include/std/type_traits (endian): Remove definition from here. + * testsuite/20_util/endian/1.cc: Rename to ... + * testsuite/26_numerics/endian/1.cc: ... here. Adjust header. + 2019-07-25 Martin Liska Dominik Infuhr diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit index f17d2f1bd59..d57433c093a 100644 --- a/libstdc++-v3/include/std/bit +++ b/libstdc++-v3/include/std/bit @@ -315,6 +315,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION log2p1(_Tp __x) noexcept { return std::__log2p1(__x); } + /// Byte order + enum class endian + { + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ + }; #endif // C++2a _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index d8ed1ce120d..9428dadc9d7 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3226,14 +3226,6 @@ template #endif // C++17 #if __cplusplus > 201703L - /// Byte order - enum class endian - { - little = __ORDER_LITTLE_ENDIAN__, - big = __ORDER_BIG_ENDIAN__, - native = __BYTE_ORDER__ - }; - /// Remove references and cv-qualifiers. template struct remove_cvref diff --git a/libstdc++-v3/testsuite/20_util/endian/1.cc b/libstdc++-v3/testsuite/20_util/endian/1.cc deleted file mode 100644 index 4faaba8e541..00000000000 --- a/libstdc++-v3/testsuite/20_util/endian/1.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2017-2019 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include - -static_assert( std::is_enum_v ); -static_assert( std::endian::little != std::endian::big ); -static_assert( std::endian::native == std::endian::big - || std::endian::native == std::endian::little ); - -namespace gnu { - int little, big, native; -} - -using namespace std; -using namespace gnu; - -// std::endian is a scoped-enum so these should refer to gnu::native etc. -int test = little + big + native; diff --git a/libstdc++-v3/testsuite/26_numerics/endian/1.cc b/libstdc++-v3/testsuite/26_numerics/endian/1.cc new file mode 100644 index 00000000000..896a14c5a6c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/endian/1.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2017-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +static_assert( std::is_enum_v ); +static_assert( std::endian::little != std::endian::big ); +static_assert( std::endian::native == std::endian::big + || std::endian::native == std::endian::little ); + +namespace gnu { + int little, big, native; +} + +using namespace std; +using namespace gnu; + +// std::endian is a scoped-enum so these should refer to gnu::native etc. +int test = little + big + native;