Make error_code, error_condition literal if C++14 constexpr is available

This commit is contained in:
Peter Dimov committed 2018-01-14 07:24:00 +02:00
1 parent d28c6ff128
commit 7b6dcf6ac6
4 files changed
+204 -88

No files matched your search

+6
View File
@@ -142,6 +142,12 @@ project
[ run before_main_test.cpp
: : : -<library>/boost/system//boost_system <define>BOOST_ERROR_CODE_HEADER_ONLY : before_main_test_header
]
[ run constexpr_test.cpp
: : : <link>static : constexpr_test_static
]
[ run constexpr_test.cpp
: : : <link>shared : constexpr_test_shared
]
;
# Quick (CI) test
+40
View File
@@ -0,0 +1,40 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
int main() {}
#else
using namespace boost::system;
constexpr error_code e1( 1, system_category() );
BOOST_STATIC_ASSERT( e1.value() == 1 );
BOOST_STATIC_ASSERT( e1.category() == system_category() );
constexpr error_code e2( 2, generic_category() );
BOOST_STATIC_ASSERT( e2.value() == 2 );
BOOST_STATIC_ASSERT( e2.category() == generic_category() );
int main()
{
error_code e1_( 1, system_category() );
BOOST_TEST_EQ( e1, e1_ );
error_code e2_( 2, generic_category() );
BOOST_TEST_EQ( e2, e2_ );
return boost::report_errors();
}
#endif