Skip to content

Commit

Permalink
Reverting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Sep 27, 2024
1 parent 6f98430 commit b65362d
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 156 deletions.
42 changes: 21 additions & 21 deletions example/error_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@
// not captured, only printed.

#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

#include <iostream>
#include <cstdlib>

Expand Down Expand Up @@ -146,3 +125,24 @@ int main()
} );
return 0;
}

////////////////////////////////////////

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif
42 changes: 21 additions & 21 deletions example/error_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@
// recorded in a std::deque, rather than just printed in-place.

#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

#include <iostream>
#include <deque>
#include <cstdlib>
Expand Down Expand Up @@ -146,3 +125,24 @@ int main()
} );
return 0;
}

////////////////////////////////////////

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif
42 changes: 20 additions & 22 deletions example/lua_callback_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,11 @@
// This is a simple program that shows how to report error objects out of a
// C-callback, converting them to leaf::result<T> as soon as controlreaches C++.

#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

extern "C" {
#include "lua.h"
#include "lauxlib.h"
}
#include <boost/leaf.hpp>
#include <iostream>
#include <memory>
#include <stdlib.h>
Expand Down Expand Up @@ -174,3 +153,22 @@ int main()

return 0;
}

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif
42 changes: 21 additions & 21 deletions example/print_file/print_file_leaf_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,6 @@
// does use exception handling is in print_file_exceptions.cpp.

#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

#include <iostream>
#include <memory>
#include <stdio.h>
Expand Down Expand Up @@ -223,3 +202,24 @@ result<void> file_read( FILE & f, void * buf, std::size_t size )

return { };
}

////////////////////////////////////////

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif
46 changes: 23 additions & 23 deletions example/print_file/print_file_system_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@


#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

#include <boost/system/result.hpp>
#include <iostream>
#include <memory>
Expand All @@ -53,12 +32,12 @@ enum error_code


template <class T>
using result = boost::system::result<T>;
using result = boost::system::result<T, std::error_code>;

// To enable LEAF to work with boost::system::result, we need to specialize the
// is_result_type template:
namespace boost { namespace leaf {
template <class T> struct is_result_type<boost::system::result<T>>: std::true_type { };
template <class T> struct is_result_type<boost::system::result<T, std::error_code>>: std::true_type { };
} }


Expand Down Expand Up @@ -231,3 +210,24 @@ result<void> file_read( FILE & f, void * buf, std::size_t size )

return { };
}

////////////////////////////////////////

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
BOOST_NORETURN void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif
42 changes: 21 additions & 21 deletions example/print_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,6 @@
// https://github.com/ned14/outcome/blob/master/doc/src/snippets/using_result.cpp

#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

#include <algorithm>
#include <ctype.h>
#include <string>
Expand Down Expand Up @@ -117,3 +96,24 @@ int main( int argc, char const * argv[] )
return 3;
} );
}

////////////////////////////////////////

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif
42 changes: 21 additions & 21 deletions example/try_capture_all_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,6 @@ int main()
#else

#include <boost/leaf.hpp>

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

////////////////////////////////////////

#include <vector>
#include <string>
#include <future>
Expand Down Expand Up @@ -124,4 +103,25 @@ int main()
}
}

////////////////////////////////////////

#ifdef BOOST_LEAF_NO_EXCEPTIONS

namespace boost
{
[[noreturn]] void throw_exception( std::exception const & e )
{
std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what();
std::terminate();
}

struct source_location;
[[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & )
{
throw_exception(e);
}
}

#endif

#endif
Loading

0 comments on commit b65362d

Please sign in to comment.