Skip to content
Draft
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
355 changes: 355 additions & 0 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under 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

cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.5...3.31)
project(boost_throw_exception VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

add_library(boost_throw_exception INTERFACE)
Expand All @@ -16,6 +16,13 @@ target_link_libraries(boost_throw_exception
Boost::config
)

if (BOOST_USE_MODULES)
# This library exports only headers even with BOOST_USE_MODULES,
# but consuming it requires 'import std' and defining BOOST_USE_MODULES
target_compile_features(boost_throw_exception INTERFACE cxx_std_23)
target_compile_definitions(boost_throw_exception INTERFACE BOOST_USE_MODULES)
endif()

if(BUILD_TESTING)

add_subdirectory(test)
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ install:
- git submodule update --init tools/boostdep
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\throw_exception\
- python tools/boostdep/depinst/depinst.py throw_exception
- python libs/throw_exception/tools/setup_boost_with_modules.py # Temporary
- cmd /c bootstrap
- b2 -d0 headers

Expand Down
4 changes: 2 additions & 2 deletions include/boost/exception/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#include <boost/assert/source_location.hpp>
#include <boost/config.hpp>
#include <exception>
#include <boost/config/std/exception.hpp>

#ifdef BOOST_EXCEPTION_MINI_BOOST
#include <memory>
#include <boost/config/std/memory.hpp>
namespace boost { namespace exception_detail { using std::shared_ptr; } }
#else
namespace boost { template <class T> class shared_ptr; }
Expand Down
22 changes: 14 additions & 8 deletions include/boost/throw_exception.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Make the header safe to include from libraries supporting modules
#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_THROW_EXCEPTION_HPP_INCLUDED)
# error "Please #include <boost/throw_exception.hpp> in your module global fragment"
#endif

#ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED
#define BOOST_THROW_EXCEPTION_HPP_INCLUDED

Expand All @@ -22,11 +27,11 @@
#include <boost/assert/source_location.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <exception>
#include <utility>
#include <cstddef>
#include <boost/config/std/exception.hpp>
#include <boost/config/std/utility.hpp>
#include <boost/config/std/cstddef.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <type_traits>
#include <boost/config/std/type_traits.hpp>
#endif

#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x593) )
Expand Down Expand Up @@ -103,10 +108,11 @@ template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept:
{
copy_from( &e );

set_info( *this, throw_file( loc.file_name() ) );
set_info( *this, throw_line( static_cast<int>( loc.line() ) ) );
set_info( *this, throw_function( loc.function_name() ) );
set_info( *this, throw_column( static_cast<int>( loc.column() ) ) );
// RP TODO: gcc fails to find these by ADL when using modules for some reason
exception_detail::set_info( *this, throw_file( loc.file_name() ) );
exception_detail::set_info( *this, throw_line( static_cast<int>( loc.line() ) ) );
exception_detail::set_info( *this, throw_function( loc.function_name() ) );
exception_detail::set_info( *this, throw_column( static_cast<int>( loc.column() ) ) );
}

virtual boost::exception_detail::clone_base const * clone() const BOOST_OVERRIDE
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)

if(HAVE_BOOST_TEST)

if(BOOST_USE_MODULES)
set(CMAKE_CXX_MODULE_STD ON)
endif()

boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::throw_exception Boost::core Boost::exception)

endif()
Expand Down
2 changes: 1 addition & 1 deletion test/cmake_install_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

#include <boost/throw_exception.hpp>
#include <stdexcept>
#include <boost/config/std/stdexcept.hpp>

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion test/cmake_subdir_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

#include <boost/throw_exception.hpp>
#include <stdexcept>
#include <boost/config/std/stdexcept.hpp>

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion test/lib1_throw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/config.hpp>
#include <exception>
#include <boost/config/std/exception.hpp>

#if defined(LIB1_DYN_LINK)
# if defined(LIB1_SOURCE)
Expand Down
2 changes: 1 addition & 1 deletion test/lib2_throw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/config.hpp>
#include <exception>
#include <boost/config/std/exception.hpp>

#if defined(LIB2_DYN_LINK)
# if defined(LIB2_SOURCE)
Expand Down
2 changes: 1 addition & 1 deletion test/lib3_throw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/config.hpp>
#include <exception>
#include <boost/config/std/exception.hpp>

#if defined(LIB3_DYN_LINK)
# if defined(LIB3_SOURCE)
Expand Down
2 changes: 1 addition & 1 deletion test/lib4_throw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/config.hpp>
#include <exception>
#include <boost/config/std/exception.hpp>

#if defined(LIB4_DYN_LINK)
# if defined(LIB4_SOURCE)
Expand Down
13 changes: 13 additions & 0 deletions test/make_exception_ptr_nx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
# pragma warning(disable: 4577) // noexcept used without /EHsc
Expand All @@ -27,3 +38,5 @@ void throw_exception( std::exception const & )
}

} // namespace boost

#endif
13 changes: 13 additions & 0 deletions test/make_exception_ptr_nx_test2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
# pragma warning(disable: 4577) // noexcept used without /EHsc
Expand Down Expand Up @@ -29,3 +40,5 @@ void throw_exception( std::exception const & )
}

} // namespace boost

#endif
13 changes: 13 additions & 0 deletions test/make_exception_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
Expand All @@ -16,3 +27,5 @@ int main()
BOOST_TEST_THROWS( boost::rethrow_exception( boost::make_exception_ptr( my_exception() ) ), my_exception );
return boost::report_errors();
}

#endif
13 changes: 13 additions & 0 deletions test/make_exception_ptr_test2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
Expand All @@ -18,3 +29,5 @@ int main()
BOOST_TEST_THROWS( boost::rethrow_exception( boost::make_exception_ptr( my_exception() ) ), my_exception );
return boost::report_errors();
}

#endif
2 changes: 1 addition & 1 deletion test/throw_exception_no_both_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define BOOST_EXCEPTION_DISABLE

#include <boost/throw_exception.hpp>
#include <cstdlib>
#include <boost/config/std/cstdlib.hpp>

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
Expand Down
2 changes: 1 addition & 1 deletion test/throw_exception_no_exceptions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define BOOST_NO_EXCEPTIONS

#include <boost/throw_exception.hpp>
#include <cstdlib>
#include <boost/config/std/cstdlib.hpp>

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
Expand Down
2 changes: 1 addition & 1 deletion test/throw_exception_nx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

#include <boost/throw_exception.hpp>
#include <cstdlib>
#include <boost/config/std/cstdlib.hpp>

class my_exception: public std::exception {};

Expand Down
4 changes: 2 additions & 2 deletions test/throw_exception_nx_test2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#endif

#include <boost/throw_exception.hpp>
#include <cstdlib>
#include <cstring>
#include <boost/config/std/cstdlib.hpp>
#include <boost/config/std/cstring.hpp>

class my_exception: public std::exception {};

Expand Down
13 changes: 13 additions & 0 deletions test/throw_exception_test3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
Expand Down Expand Up @@ -109,3 +120,5 @@ int main()

return boost::report_errors();
}

#endif
21 changes: 17 additions & 4 deletions test/throw_exception_test4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#include <boost/throw_exception.hpp>
#include <boost/exception/get_error_info.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <cstring>
#include <boost/config/std/cstring.hpp>

class my_exception: public std::exception
{
Expand Down Expand Up @@ -62,7 +73,7 @@ int main()
int const * line = boost::get_error_info<boost::throw_line>( x );

BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 50 );
BOOST_TEST_EQ( *line, 61 );
}

{
Expand Down Expand Up @@ -90,7 +101,7 @@ int main()
int const * line = boost::get_error_info<boost::throw_line>( x );

BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 78 );
BOOST_TEST_EQ( *line, 89 );
}

{
Expand Down Expand Up @@ -118,7 +129,7 @@ int main()
int const * line = boost::get_error_info<boost::throw_line>( x );

BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 106 );
BOOST_TEST_EQ( *line, 117 );
}

{
Expand All @@ -131,3 +142,5 @@ int main()

return boost::report_errors();
}

#endif
15 changes: 14 additions & 1 deletion test/throw_exception_test5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#ifdef BOOST_USE_MODULES

import std.compat;

int main()
{
printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n");
}

#else

#if defined(__clang__)
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wunknown-warning-option"
Expand All @@ -16,7 +27,7 @@
#include <boost/exception/get_error_info.hpp>
#include <boost/exception/info.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
#include <boost/config/std/string.hpp>

typedef boost::error_info<struct tag_error_code, int> error_code;
typedef boost::error_info<struct tag_error_string, std::string> error_string;
Expand Down Expand Up @@ -117,3 +128,5 @@ int main()

return boost::report_errors();
}

#endif
Loading
Loading