From 5e088741827eca33013a7d78ce0b86ba3c0c22e0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 5 Sep 2018 17:06:42 +0300 Subject: [PATCH] Add initial implementation of quick_exit --- include/boost/core/quick_exit.hpp | 31 +++++++++++++++++++++++++++++++ test/Jamfile.v2 | 3 +++ test/quick_exit_fail.cpp | 17 +++++++++++++++++ test/quick_exit_test.cpp | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 include/boost/core/quick_exit.hpp create mode 100644 test/quick_exit_fail.cpp create mode 100644 test/quick_exit_test.cpp diff --git a/include/boost/core/quick_exit.hpp b/include/boost/core/quick_exit.hpp new file mode 100644 index 0000000..0dbadfc --- /dev/null +++ b/include/boost/core/quick_exit.hpp @@ -0,0 +1,31 @@ +#ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED +#define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// boost/core/quick_exit.hpp +// +// Copyright 2018 Peter Dimov +// +// 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) + +#include +#include + +namespace boost +{ + +void quick_exit( int code ) +{ + std::quick_exit( code ); +} + +} // namespace boost + +#endif // #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c714d56..f9adee2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -127,5 +127,8 @@ run exchange_move_test.cpp ; run empty_value_test.cpp ; run empty_value_size_test.cpp ; +run quick_exit_test.cpp ; +run-fail quick_exit_fail.cpp ; + use-project /boost/core/swap : ./swap ; build-project ./swap ; diff --git a/test/quick_exit_fail.cpp b/test/quick_exit_fail.cpp new file mode 100644 index 0000000..b1d394e --- /dev/null +++ b/test/quick_exit_fail.cpp @@ -0,0 +1,17 @@ + +// Test for quick_exit.hpp +// +// Copyright 2018 Peter Dimov +// +// 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 + + +#include + +int main() +{ + boost::quick_exit( 1 ); + return 0; +} diff --git a/test/quick_exit_test.cpp b/test/quick_exit_test.cpp new file mode 100644 index 0000000..e5f7795 --- /dev/null +++ b/test/quick_exit_test.cpp @@ -0,0 +1,17 @@ + +// Test for quick_exit.hpp +// +// Copyright 2018 Peter Dimov +// +// 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 + + +#include + +int main() +{ + boost::quick_exit( 0 ); + return 1; +}