Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/boost/describe/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@

#define BOOST_DESCRIBE_INLINE_CONSTEXPR BOOST_DESCRIBE_INLINE_VARIABLE BOOST_DESCRIBE_CONSTEXPR_OR_CONST

#if __cplusplus >= 201703L || ( defined(_MSVC_LANG) && _MSVC_LANG >= 201703L )

# define BOOST_DESCRIBE_CXX17_CONSTEXPR constexpr
# define BOOST_DESCRIBE_HAS_CXX17_CONSTEXPR

#else

# define BOOST_DESCRIBE_CXX17_CONSTEXPR

#endif

#if __cplusplus >= 202002L || ( defined(_MSVC_LANG) && _MSVC_LANG >= 202002L )

# define BOOST_DESCRIBE_CXX20
Expand Down
2 changes: 1 addition & 1 deletion include/boost/describe/enum_to_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace describe
{

template<class E, class De = describe_enumerators<E>>
char const * enum_to_string( E e, char const* def ) noexcept
BOOST_DESCRIBE_CXX17_CONSTEXPR char const * enum_to_string( E e, char const* def ) noexcept
{
char const * r = def;

Expand Down
4 changes: 4 additions & 0 deletions test/enum_to_string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ int main()
BOOST_TEST_CSTR_EQ( enum_to_string( E4::v4, "" ), "v4" );
BOOST_TEST_EQ( enum_to_string( static_cast<E4>( 14 ), 0 ), static_cast<char const*>( 0 ) );

#if defined(BOOST_DESCRIBE_HAS_CXX17_CONSTEXPR)
static_assert(enum_to_string(E2::v2, "")[1] == '2');
static_assert(enum_to_string(static_cast<E2>(10), "")[0] == 0);
#endif
return boost::report_errors();
}

Expand Down
Loading