mirror of
https://github.com/boostorg/describe.git
synced 2026-01-19 16:12:19 +00:00
Compare commits
11 Commits
boost-1.90
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4959611e09 | ||
|
|
a722380b2a | ||
|
|
dfd9182bf3 | ||
|
|
f1774f3d02 | ||
|
|
7c0d234267 | ||
|
|
6e4b7f5a07 | ||
|
|
0a40d3b824 | ||
|
|
644a984a61 | ||
|
|
43ee545507 | ||
|
|
54b73c7ca7 | ||
|
|
ee215421cb |
@@ -370,12 +370,19 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 25.04 Clang 20",
|
||||
"cppalliance/droneubuntu2504:1",
|
||||
"Linux 24.04 Clang 20",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '03,11,14,17,20,23,2c' },
|
||||
"clang-20",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 25.10 Clang 21",
|
||||
"cppalliance/droneubuntu2510:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '03,11,14,17,20,23,2c' },
|
||||
"clang-21",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
|
||||
@@ -386,6 +393,18 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.2.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "13.2.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.2.1 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
xcode_version = "13.2.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
@@ -398,6 +417,18 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 14 Xcode 16.2.0 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "16.2.0", osx_version = "sonoma", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 14 Xcode 16.2.0 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
xcode_version = "16.2.0", osx_version = "sonoma", arch = "arm64",
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2015 msvc-14.0",
|
||||
"cppalliance/dronevs2015",
|
||||
|
||||
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
@@ -67,6 +67,11 @@ jobs:
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-14
|
||||
- toolset: gcc-15
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
container: ubuntu:25.10
|
||||
os: ubuntu-latest
|
||||
install: g++-15
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
@@ -170,14 +175,26 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
install: clang-19
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-13
|
||||
compiler: clang++-20
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-20
|
||||
- toolset: clang
|
||||
compiler: clang++-21
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
container: ubuntu:25.10
|
||||
os: ubuntu-latest
|
||||
install: clang-21
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-15
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -310,9 +327,9 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -358,9 +375,9 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -416,9 +433,9 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
|
||||
@@ -24,9 +24,13 @@ environment:
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17,20,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17,latest
|
||||
CXXSTD: 14,17,20,latest
|
||||
ADDRMD: 32,64
|
||||
|
||||
install:
|
||||
|
||||
@@ -8,6 +8,11 @@ https://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix:
|
||||
|
||||
## Changes in Boost 1.91.0
|
||||
|
||||
* Under {cpp}20, described nested enums now work when the enclosing class is still incomplete. (Thanks to Julien Blanc.)
|
||||
* Made `enum_to_string` constexpr. (Thanks to Julien Blanc.)
|
||||
|
||||
## Changes in Boost 1.84.0
|
||||
|
||||
* Added an overload of `enum_from_string` that takes a string view, to avoid
|
||||
|
||||
@@ -45,4 +45,20 @@
|
||||
|
||||
#define BOOST_DESCRIBE_INLINE_CONSTEXPR BOOST_DESCRIBE_INLINE_VARIABLE BOOST_DESCRIBE_CONSTEXPR_OR_CONST
|
||||
|
||||
#if __cplusplus >= 202002L || ( defined(_MSVC_LANG) && _MSVC_LANG >= 202002L )
|
||||
|
||||
# define BOOST_DESCRIBE_CXX20
|
||||
|
||||
// Clang 13.0 is needed for unevaluated lambdas
|
||||
# if defined(__clang__) && __clang_major__ < 13
|
||||
# undef BOOST_DESCRIBE_CXX20
|
||||
# endif
|
||||
|
||||
// Apple Clang 13.1 is Clang 13.0
|
||||
# if defined(__clang__) && defined(__apple_build_version__) && __clang_major__ == 13 && __clang_minor__ < 1
|
||||
# undef BOOST_DESCRIBE_CXX20
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_DESCRIBE_DETAIL_CONFIG_HPP_INCLUDED
|
||||
|
||||
@@ -43,6 +43,23 @@ template<class... T> auto enum_descriptor_fn_impl( int, T... )
|
||||
return list<enum_descriptor<T>...>();
|
||||
}
|
||||
|
||||
#if defined(BOOST_DESCRIBE_CXX20)
|
||||
|
||||
template<auto V, auto N> struct enum_desc
|
||||
{
|
||||
static constexpr auto value() noexcept { return V; }
|
||||
static constexpr auto name() noexcept { return N(); }
|
||||
};
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_BEGIN(E) \
|
||||
inline decltype( boost::describe::detail::enum_descriptor_fn_impl( 0
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_ENTRY(E, e) , boost::describe::detail::enum_desc<E::e, []{ return #e; }>{}
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_END(E) ) ) boost_enum_descriptor_fn( E** ) { return {}; }
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_BEGIN(E) \
|
||||
inline auto boost_enum_descriptor_fn( E** ) \
|
||||
{ return boost::describe::detail::enum_descriptor_fn_impl( 0
|
||||
@@ -53,6 +70,8 @@ template<class... T> auto enum_descriptor_fn_impl( int, T... )
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_END(E) ); }
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
|
||||
#define BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
|
||||
|
||||
// Copyright 2020, 2021 Peter Dimov
|
||||
// Copyright 2020, 2021, 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
@@ -22,16 +22,34 @@ namespace boost
|
||||
namespace describe
|
||||
{
|
||||
|
||||
template<class E, class De = describe_enumerators<E>>
|
||||
char const * enum_to_string( E e, char const* def ) noexcept
|
||||
namespace detail
|
||||
{
|
||||
char const * r = def;
|
||||
|
||||
mp11::mp_for_each<De>([&](auto D){
|
||||
// [&](auto D){ if( e == D.value ) r = D.name; }
|
||||
// except constexpr under C++14
|
||||
|
||||
if( e == D.value ) r = D.name;
|
||||
template<class E> struct ets_lambda
|
||||
{
|
||||
E e;
|
||||
char const** pr;
|
||||
|
||||
});
|
||||
template<class D> constexpr void operator()( D d ) const noexcept
|
||||
{
|
||||
if( e == d.value ) *pr = d.name;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class E, class De = describe_enumerators<E>>
|
||||
#if !( defined(_MSC_VER) && _MSC_VER == 1900 )
|
||||
constexpr
|
||||
#endif
|
||||
char const* enum_to_string( E e, char const* def ) noexcept
|
||||
{
|
||||
char const* r = def;
|
||||
|
||||
mp11::mp_for_each<De>( detail::ets_lambda<E>{ e, &r } );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ run pedantic_members_test.cpp
|
||||
|
||||
run enum_from_string_test2.cpp ;
|
||||
|
||||
compile nested_enum_test2.cpp ;
|
||||
|
||||
compile enum_to_string_test_cx.cpp ;
|
||||
|
||||
# examples
|
||||
|
||||
obj describe_cxx14 : describe_cxx14.cpp ;
|
||||
|
||||
32
test/enum_to_string_test_cx.cpp
Normal file
32
test/enum_to_string_test_cx.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2021, 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/enum_to_string.hpp>
|
||||
#include <boost/describe/enum.hpp>
|
||||
#include <boost/describe/detail/cx_streq.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available")
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER == 1900
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because _MSC_VER == 1900")
|
||||
|
||||
#else
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
BOOST_DEFINE_ENUM_CLASS(E, v1, v2, v3)
|
||||
|
||||
using boost::describe::enum_to_string;
|
||||
using boost::describe::detail::cx_streq;
|
||||
|
||||
STATIC_ASSERT( cx_streq( enum_to_string( E::v1, "" ), "v1" ) );
|
||||
STATIC_ASSERT( cx_streq( enum_to_string( E::v2, "" ), "v2" ) );
|
||||
STATIC_ASSERT( cx_streq( enum_to_string( E::v3, "" ), "v3" ) );
|
||||
STATIC_ASSERT( cx_streq( enum_to_string( (E)17, "def" ), "def" ) );
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
24
test/nested_enum_test2.cpp
Normal file
24
test/nested_enum_test2.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/enumerators.hpp>
|
||||
#include <boost/describe/enum.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX20)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_DESCRIBE_CXX20 isn't defined")
|
||||
|
||||
#else
|
||||
|
||||
struct X
|
||||
{
|
||||
enum E { v1 };
|
||||
BOOST_DESCRIBE_NESTED_ENUM(E, v1)
|
||||
|
||||
using L = boost::describe::describe_enumerators<E>;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user