Compare commits

...

10 Commits

9 changed files with 180 additions and 14 deletions

View File

@@ -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",

View File

@@ -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}}

View File

@@ -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

View File

@@ -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

View File

@@ -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__)

View File

@@ -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;
}

View File

@@ -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 ;

View 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)

View 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