Skip to content

Commit

Permalink
Attempt to solve issue boostorg#284
Browse files Browse the repository at this point in the history
Added defect macro BOOST_NO_CXX11_HDR_EXCEPTION

Should be #define'd when:
The standard library does not provide a C++11 compatible version of <exception>.

To solve Boost.Exception issue boostorg/exception#10 I need to detect
compiler support for C++11 compliant:
 - std::exception_ptr
 - std::current_exception()
 - std::rethrow_exception()
  • Loading branch information
dmenendez-gruposantander committed Jun 4, 2019
1 parent f76000b commit 7e9fd9f
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ You can either run all the tests listed in `Jamfile.v2` or run a single test:
../../../b2 <- run all tests
../../../b2 config_info <- single test

### For developers ###
Please check the [Guidelines for Boost Authors](http://www.boost.org/doc/libs/release/libs/config/doc/html/boost_config/guidelines_for_boost_authors.html). from the full documentation.
3 changes: 2 additions & 1 deletion checks/Jamfile.v2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# *** DO NOT EDIT THIS FILE BY HAND ***
# This file was automatically generated on Sun Apr 21 09:13:03 2019
# This file was automatically generated on Tue Jun 4 10:08:17 2019
# by libs/config/tools/generate.cpp
# Copyright John Maddock.
# Use, modification and distribution are subject to the
Expand Down Expand Up @@ -75,6 +75,7 @@ obj cxx11_hdr_atomic : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_ATOMIC ;
obj cxx11_hdr_chrono : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_CHRONO ;
obj cxx11_hdr_codecvt : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_CODECVT ;
obj cxx11_hdr_condition_variable : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_CONDITION_VARIABLE ;
obj cxx11_hdr_exception : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_EXCEPTION ;
obj cxx11_hdr_forward_list : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_FORWARD_LIST ;
obj cxx11_hdr_future : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_FUTURE ;
obj cxx11_hdr_initializer_list : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_INITIALIZER_LIST ;
Expand Down
7 changes: 6 additions & 1 deletion checks/test_case.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was automatically generated on Sun Apr 21 09:13:03 2019
// This file was automatically generated on Tue Jun 4 10:08:17 2019
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
Expand Down Expand Up @@ -331,6 +331,11 @@
# error "Defect macro BOOST_NO_CXX11_HDR_CONDITION_VARIABLE is defined."
# endif
#endif
#ifdef TEST_BOOST_NO_CXX11_HDR_EXCEPTION
# ifdef BOOST_NO_CXX11_HDR_EXCEPTION
# error "Defect macro BOOST_NO_CXX11_HDR_EXCEPTION is defined."
# endif
#endif
#ifdef TEST_BOOST_NO_CXX11_HDR_FORWARD_LIST
# ifdef BOOST_NO_CXX11_HDR_FORWARD_LIST
# error "Defect macro BOOST_NO_CXX11_HDR_FORWARD_LIST is defined."
Expand Down
1 change: 1 addition & 0 deletions doc/macro_reference.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ default template arguments for function templates.
[[`BOOST_NO_CXX11_HDR_CHRONO`][The standard library does not provide header <chrono>.]]
[[`BOOST_NO_CXX11_HDR_CODECVT`][The standard library does not provide header <codecvt>.]]
[[`BOOST_NO_CXX11_HDR_CONDITION_VARIABLE`][The standard library does not provide header <condition_variable>.]]
[[`BOOST_NO_CXX11_HDR_EXCEPTION`][The standard library does not provide a C++11 compatible version of <exception>.]]
[[`BOOST_NO_CXX11_HDR_FORWARD_LIST`][The standard library does not provide header <forward_list>.]]
[[`BOOST_NO_CXX11_HDR_FUNCTIONAL`][The standard library does not provide a C++11 compatible version of <functional>.]]
[[`BOOST_NO_CXX11_HDR_FUTURE`][The standard library does not provide header <future>.]]
Expand Down
5 changes: 4 additions & 1 deletion test/all/Jamfile.v2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Regression test Jamfile for boost configuration setup.
# *** DO NOT EDIT THIS FILE BY HAND ***
# This file was automatically generated on Sun Apr 21 09:13:03 2019
# This file was automatically generated on Tue Jun 4 10:08:17 2019
# by libs/config/tools/generate.cpp
# Copyright John Maddock.
# Use, modification and distribution are subject to the
Expand Down Expand Up @@ -214,6 +214,9 @@ test-suite "BOOST_NO_CXX11_HDR_CODECVT" :
test-suite "BOOST_NO_CXX11_HDR_CONDITION_VARIABLE" :
[ run ../no_cxx11_hdr_condition_variable_pass.cpp ]
[ compile-fail ../no_cxx11_hdr_condition_variable_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_HDR_EXCEPTION" :
[ run ../no_cxx11_hdr_exception_pass.cpp ]
[ compile-fail ../no_cxx11_hdr_exception_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_HDR_FORWARD_LIST" :
[ run ../no_cxx11_hdr_forward_list_pass.cpp ]
[ compile-fail ../no_cxx11_hdr_forward_list_fail.cpp ] ;
Expand Down
40 changes: 40 additions & 0 deletions test/boost_no_cxx11_hdr_exception.ipp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// (C) Copyright Beman Dawes 2009

// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// See http://www.boost.org/libs/config for more information.

// MACRO: BOOST_NO_CXX11_HDR_EXCEPTION
// TITLE: C++11 header <exception> unavailable
// DESCRIPTION: The standard library does not provide a C++11 compatible version of <exception>.

#include <exception>

namespace boost_no_cxx11_hdr_exception {

int test()
{
std::exception_ptr ep;
try
{
throw 42;
}
catch(...)
{
ep = std::current_exception();
}
try
{
std::rethrow_exception(ep);
}
catch(int i)
{
// return zero on success
return i == 42 ? 0 : 1;
}
return 1;
}

}
4 changes: 4 additions & 0 deletions test/config_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ void print_boost_macros()
PRINT_MACRO(BOOST_NO_CXX11_HDR_CHRONO);
PRINT_MACRO(BOOST_NO_CXX11_HDR_CODECVT);
PRINT_MACRO(BOOST_NO_CXX11_HDR_CONDITION_VARIABLE);
PRINT_MACRO(BOOST_NO_CXX11_HDR_EXCEPTION);
PRINT_MACRO(BOOST_NO_CXX11_HDR_FORWARD_LIST);
PRINT_MACRO(BOOST_NO_CXX11_HDR_FUNCTIONAL);
PRINT_MACRO(BOOST_NO_CXX11_HDR_FUTURE);
Expand Down Expand Up @@ -1247,6 +1248,9 @@ void print_boost_macros()









Expand Down
12 changes: 11 additions & 1 deletion test/config_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was automatically generated on Sun Apr 21 09:13:03 2019
// This file was automatically generated on Tue Jun 4 10:08:17 2019
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
Expand Down Expand Up @@ -157,6 +157,11 @@ namespace boost_no_cxx11_hdr_codecvt = empty_boost;
#else
namespace boost_no_cxx11_hdr_condition_variable = empty_boost;
#endif
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
#include "boost_no_cxx11_hdr_exception.ipp"
#else
namespace boost_no_cxx11_hdr_exception = empty_boost;
#endif
#ifndef BOOST_NO_CXX11_HDR_FORWARD_LIST
#include "boost_no_cxx11_hdr_forward_list.ipp"
#else
Expand Down Expand Up @@ -1331,6 +1336,11 @@ int main( int, char *[] )
std::cerr << "Failed test for BOOST_NO_CXX11_HDR_CONDITION_VARIABLE at: " << __FILE__ << ":" << __LINE__ << std::endl;
++error_count;
}
if(0 != boost_no_cxx11_hdr_exception::test())
{
std::cerr << "Failed test for BOOST_NO_CXX11_HDR_EXCEPTION at: " << __FILE__ << ":" << __LINE__ << std::endl;
++error_count;
}
if(0 != boost_no_cxx11_hdr_forward_list::test())
{
std::cerr << "Failed test for BOOST_NO_CXX11_HDR_FORWARD_LIST at: " << __FILE__ << ":" << __LINE__ << std::endl;
Expand Down
37 changes: 37 additions & 0 deletions test/no_cxx11_hdr_exception_fail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file was automatically generated on Tue Jun 4 10:08:17 2019
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// See http://www.boost.org/libs/config for the most recent version.//
// Revision $Id$
//


// Test file for macro BOOST_NO_CXX11_HDR_EXCEPTION
// This file should not compile, if it does then
// BOOST_NO_CXX11_HDR_EXCEPTION should not be defined.
// See file boost_no_cxx11_hdr_exception.ipp for details

// Must not have BOOST_ASSERT_CONFIG set; it defeats
// the objective of this file:
#ifdef BOOST_ASSERT_CONFIG
# undef BOOST_ASSERT_CONFIG
#endif

#include <boost/config.hpp>
#include "test.hpp"

#ifdef BOOST_NO_CXX11_HDR_EXCEPTION
#include "boost_no_cxx11_hdr_exception.ipp"
#else
#error "this file should not compile"
#endif

int main( int, char *[] )
{
return boost_no_cxx11_hdr_exception::test();
}

37 changes: 37 additions & 0 deletions test/no_cxx11_hdr_exception_pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file was automatically generated on Tue Jun 4 10:08:17 2019
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// See http://www.boost.org/libs/config for the most recent version.//
// Revision $Id$
//


// Test file for macro BOOST_NO_CXX11_HDR_EXCEPTION
// This file should compile, if it does not then
// BOOST_NO_CXX11_HDR_EXCEPTION should be defined.
// See file boost_no_cxx11_hdr_exception.ipp for details

// Must not have BOOST_ASSERT_CONFIG set; it defeats
// the objective of this file:
#ifdef BOOST_ASSERT_CONFIG
# undef BOOST_ASSERT_CONFIG
#endif

#include <boost/config.hpp>
#include "test.hpp"

#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
#include "boost_no_cxx11_hdr_exception.ipp"
#else
namespace boost_no_cxx11_hdr_exception = empty_boost;
#endif

int main( int, char *[] )
{
return boost_no_cxx11_hdr_exception::test();
}

0 comments on commit 7e9fd9f

Please sign in to comment.