1
0
forked from boostorg/core

Compare commits

..

40 Commits

Author SHA1 Message Date
Glen Fernandes
690514e87c Use BOOST_INLINE_CONSTEXPR in empty_value 2020-04-05 19:55:24 -04:00
Peter Dimov
5a5d2adda0 Go back to ::quick_exit, but include the correct <stdlib.h>; on Linux and Cygwin, quick_exit is not brought into std in C++03 mode 2020-03-23 15:54:23 +02:00
Peter Dimov
10c01d0d56 Use std::quick_exit instead of ::quick_exit 2020-03-23 05:21:08 +02:00
Peter Dimov
27d8ef1286 Change BOOST_TEST to match BOOST_TEST_EQ et al, in order to avoid 'expression result unused' warning from Clang 2020-02-21 19:46:42 +02:00
Glen Fernandes
b5c2726d1b Include cstddef in pointer_traits 2020-02-17 22:13:10 -05:00
Peter Dimov
0eecbda0b1 Remove unnecessary struct 2020-02-17 05:21:20 +02:00
Peter Dimov
2a471c3417 Add test for BOOST_TEST_* macros return values 2020-02-16 20:52:59 +02:00
Peter Dimov
5ca752323f Return a bool result from the BOOST_TEST_* macros, f.ex. to allow chaining with && 2020-02-16 20:52:12 +02:00
Peter Dimov
13e9d3d4d9 Fix typo in test/Jamfile 2020-02-16 20:17:52 +02:00
Peter Dimov
f3cd812ccb Disable 'should return report_errors()' test on CMake, because CTest doesn't like abort() 2020-01-02 21:05:07 +02:00
Peter Dimov
8f2841de83 Restrict clang-3.5 to 03/11 to avoid ::gets error 2020-01-02 21:04:06 +02:00
Peter Dimov
bf5778403e Update tools/cmake 2020-01-02 20:30:03 +02:00
Peter Dimov
fc285464aa Update Travis to Xenial 2020-01-02 20:23:07 +02:00
Peter Dimov
750625272f Add CMake tests 2020-01-02 20:00:11 +02:00
Peter Dimov
bda2b9b4b1 Disable _CrtDbgReport message boxes, displayed on debug iterator violations 2020-01-01 17:17:43 +02:00
Glen Fernandes
ac4c781cac Include lightweight_test from core and workaround from config 2020-01-01 09:02:46 -05:00
Peter Dimov
72ca0d8664 Add CMake install support 2019-12-28 18:47:11 +02:00
Glen Fernandes
253b07f630 Add empty_init constant to documentation 2019-12-15 12:46:55 -05:00
Peter Dimov
e59271fdc2 Check BOOST_MSVC in addition to __cplusplus, because msvc doesn't define __cplusplus correctly 2019-12-02 02:15:55 +02:00
Nikita Kniazev
bc82adcd0b Remove implementation specific handling 2019-12-02 01:11:04 +03:00
Nikita Kniazev
868cb07578 Try to include std::swap from the most lightweight header
Based on Boost.Move idea
2019-12-01 17:28:07 +03:00
Andrey Semashev
38f71361fb Add a convenience instance of empty_init_t (#65)
* Added a convenience instance of empty_init_t.

Closes https://github.com/boostorg/core/issues/63.
2019-11-23 21:00:59 -05:00
Peter Dimov
6d62fb5f5e Remove clang-win 32 bit, because it fails to link with 'unable to load mspdbcore.dll (error code: 126)' 2019-11-23 21:52:53 +02:00
Peter Dimov
0d71f42365 Separate Appveyor Clang configurations 2019-11-23 21:11:26 +02:00
Peter Dimov
259587da7f Add clang-9 to Travis 2019-10-11 21:34:55 +03:00
Peter Dimov
882a792856 Add 2019 to Appveyor 2019-10-11 18:50:35 +03:00
Peter Dimov
130c8f2439 Disable Wsign-compare on gcc 4.4.7 2019-10-11 17:19:01 +03:00
Peter Dimov
e38997be4d Reorder conditions to support clang-cl 2019-10-11 16:43:48 +03:00
Peter Dimov
d112d23e9d Test that BOOST_TEST_EQ doesn't emit sign-compare warnings 2019-10-11 16:02:45 +03:00
Glen Fernandes
e94af0d41a Also define make_nvp in boost::serialization 2019-10-01 08:14:07 -04:00
Glen Fernandes
ac427ad64a Define nvp inside boost::serialization and bring it into boost 2019-10-01 07:28:25 -04:00
Glen Fernandes
f2644886f5 Update section title in documentation 2019-10-01 07:28:06 -04:00
Glen Fernandes
0591b1d855 Add BOOST_NVP convenience macro 2019-09-16 02:15:53 -04:00
Glen Fernandes
7cc1047ab7 Update NVP implementation, tests, docs 2019-09-15 21:12:16 -04:00
Glen Fernandes
f52dec58c2 Add a definition for nvp_bool 2019-09-10 08:04:40 -04:00
Glen Fernandes
26497003f2 Remove save and load helpers and update documentation for NVP 2019-09-04 21:47:39 -04:00
Glen Fernandes
5fb5a3e292 Update nvp tests and documentation 2019-09-04 12:28:00 -04:00
Glen Fernandes
7b8385afc3 Implement NVP in Core for Serialization and other libraries 2019-09-04 09:58:04 -04:00
Glen Fernandes
106a7c0939 Mark throw_exception BOOST_NORETURN 2019-08-27 07:28:28 -04:00
Peter Dimov
f2ee17fa24 Update .travis.yml 2019-07-25 12:27:19 +03:00
72 changed files with 603 additions and 149 deletions

View File

@@ -1,12 +1,10 @@
# Copyright 2016-2018 Peter Dimov
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
python: "2.7"
dist: xenial
branches:
only:
@@ -99,7 +97,6 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
@@ -120,12 +117,22 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-8
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
@@ -134,13 +141,31 @@ matrix:
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
dist: trusty
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
@@ -151,7 +176,16 @@ matrix:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
@@ -162,7 +196,6 @@ matrix:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
@@ -173,7 +206,6 @@ matrix:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
@@ -186,7 +218,6 @@ matrix:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
@@ -197,7 +228,6 @@ matrix:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
@@ -208,7 +238,6 @@ matrix:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-7
@@ -219,21 +248,44 @@ matrix:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-6.0
- libstdc++-5-dev
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-8
- os: linux
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
compiler: clang++-8
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- os: linux
dist: trusty
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
@@ -243,6 +295,7 @@ matrix:
- libc++abi-dev
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
@@ -272,14 +325,36 @@ matrix:
osx_image: xcode10.1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
env: CMAKE_TEST=1
script:
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=core ..
- ctest --output-on-failure -R boost_core
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="assert;config;core" -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/core/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
@@ -295,6 +370,7 @@ install:
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule init tools/cmake
- git submodule update --jobs 4
- cp -r $TRAVIS_BUILD_DIR/* libs/core
- ./bootstrap.sh

View File

@@ -1,13 +1,10 @@
# Copyright 2018 Peter Dimov
# Copyright 2018, 2019 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
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.5)
project(BoostCore LANGUAGES CXX)
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_core INTERFACE)
add_library(Boost::core ALIAS boost_core)
@@ -15,7 +12,20 @@ add_library(Boost::core ALIAS boost_core)
target_include_directories(boost_core INTERFACE include)
target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
INTERFACE
Boost::assert
Boost::config
)
if(BOOST_SUPERPROJECT_VERSION)
include(BoostInstall)
boost_install(TARGETS boost_core HEADER_DIRECTORY include/)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -22,7 +22,19 @@ environment:
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1,clang-win
TOOLSET: msvc-14.1
ADDRMD: 32,64
CXXSTD: 14,17
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
ADDRMD: 64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17

View File

@@ -55,6 +55,7 @@ criteria for inclusion is that the utility component be:
[include noinit_adaptor.qbk]
[include noncopyable.qbk]
[include null_deleter.qbk]
[include nvp.qbk]
[include pointer_traits.qbk]
[include quick_exit.qbk]
[include ref.qbk]

View File

@@ -97,6 +97,8 @@ public:
T& get() noexcept;
};
inline constexpr empty_init_t empty_init{ };
} /* boost */
```

108
doc/nvp.qbk Normal file
View File

@@ -0,0 +1,108 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:nvp nvp]
[section Overview]
The header <boost/core/nvp.hpp> provides the class template `boost::nvp` that
pairs a name (`const char*`) with the address of a value (`T*`). It is the new
implementation of the NVP type previously provided by the Boost Serialization
library. This type now lives in the Core library so that other Boost libraries
can support named value serialization without taking a dependency on the
Serialization library.
[endsect]
[section Examples]
The following snippet shows use in a member serialize function:
```
template<class A>
void serialize(A& archive, unsigned)
{
archive & boost::make_nvp("x", x_) & boost::make_nvp("y", y_);
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class T>
class nvp {
public:
nvp(const char* name, T& value) noexcept;
const char* name() const noexcept;
T& value() const noexcept;
const T& const_value() const noexcept;
};
template<class T>
const nvp<T> make_nvp(const char* name, T& value) noexcept;
} /* boost */
#define BOOST_NVP(object) ``['see below]``
```
[section Constructors]
[variablelist
[[`nvp(const char* name, T& value) noexcept;`]
[Initializes the stored name pointer with `name` and the value pointer with
`addressof(value)`.]]]
[endsect]
[section Members]
[variablelist
[[`const char* name() const noexcept;`]
[Returns a pointer to the name.]]
[[`T& value() const noexcept;`]
[Returns a reference to the value.]]
[[`const T& const_value() const noexcept;`]
[Returns a reference to the value.]]]
[endsect]
[section Functions]
[variablelist
[[`template<class T> const nvp<T> make_nvp(const char* name, T& value)
noexcept;`]
[Returns `nvp<T>(name, value)`.]]]
[endsect]
[section Macros]
[variablelist
[[`#define BOOST_NVP(object) see below`]
[Expands to `boost::make_nvp(BOOST_STRINGIZE(object), object)`.]]]
[endsect]
[endsect]
[section History]
Robert Ramey originally implemented NVP in the Serialization library. Glen
Fernandes implemented this new (but compatible) version in the Core library.
[endsect]
[endsect]

View File

@@ -19,7 +19,7 @@ Distributed under the Boost Software License, Version 1.0.
namespace boost {
#if defined(BOOST_NO_EXCEPTIONS)
void throw_exception(const std::exception&);
BOOST_NORETURN void throw_exception(const std::exception&);
#endif
namespace default_ {

View File

@@ -139,6 +139,8 @@ public:
using empty_::empty_value;
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
} /* boost */
#endif

View File

@@ -30,6 +30,10 @@
#include <cstring>
#include <cstddef>
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
# include <crtdbg.h>
#endif
// IDE's like Visual Studio perform better if output goes to std::cout or
// some other stream, so allow user to configure output stream:
#ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM
@@ -48,7 +52,13 @@ public:
: report_(false)
, errors_(0) {
#if defined(_MSC_VER) && (_MSC_VER > 1310)
// disable message boxes on assert(), abort()
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
// disable message boxes on iterator debugging violations
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
#endif
}
@@ -83,12 +93,21 @@ inline int& test_errors()
return test_results().errors();
}
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
if( v )
{
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void error_impl(char const * msg, char const * file, int line, char const * function)
@@ -110,14 +129,14 @@ inline void throw_failed_impl(char const * excep, char const * file, int line, c
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
// the dependency we just disable the warnings.
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__clang__) && defined(__has_warning)
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-compare"
# endif
#elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
@@ -174,13 +193,14 @@ struct lw_test_ge {
};
template<class BinaryPredicate, class T, class U>
inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
char const * file, int line, char const * function,
T const & t, U const & u)
{
if( pred(t, u) )
{
test_results();
return true;
}
else
{
@@ -189,15 +209,17 @@ inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
<< "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
inline bool test_cstr_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( std::strcmp(t, u) == 0 )
{
test_results();
return true;
}
else
{
@@ -205,15 +227,17 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
inline bool test_cstr_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( std::strcmp(t, u) != 0 )
{
test_results();
return true;
}
else
{
@@ -221,11 +245,12 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2>
void test_all_eq_impl(FormattedOutputFunction& output,
bool test_all_eq_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end)
@@ -284,16 +309,18 @@ void test_all_eq_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate>
void test_all_with_impl(FormattedOutputFunction& output,
bool test_all_with_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end,
@@ -353,20 +380,22 @@ void test_all_with_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__) && defined(__has_warning)
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic pop
# endif
#elif defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic pop
#endif
@@ -397,7 +426,7 @@ inline int report_errors()
} // namespace boost
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )

View File

@@ -0,0 +1,57 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_NVP_HPP
#define BOOST_CORE_NVP_HPP
#include <boost/core/addressof.hpp>
#include <boost/config.hpp>
namespace boost {
namespace serialization {
template<class T>
class nvp {
public:
nvp(const char* n, T& v) BOOST_NOEXCEPT
: n_(n)
, v_(boost::addressof(v)) { }
const char* name() const BOOST_NOEXCEPT {
return n_;
}
T& value() const BOOST_NOEXCEPT {
return *v_;
}
const T& const_value() const BOOST_NOEXCEPT {
return *v_;
}
private:
const char* n_;
T* v_;
};
template<class T>
inline const nvp<T>
make_nvp(const char* n, T& v) BOOST_NOEXCEPT
{
return nvp<T>(n, v);
}
} /* serialization */
using serialization::nvp;
using serialization::make_nvp;
} /* boost */
#define BOOST_NVP(v) boost::make_nvp(BOOST_STRINGIZE(v), v)
#endif

View File

@@ -13,6 +13,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <memory>
#else
#include <boost/core/addressof.hpp>
#include <cstddef>
#endif
namespace boost {

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <cstdlib>
#include <stdlib.h>
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)

View File

@@ -23,8 +23,11 @@
#include <boost/core/enable_if.hpp>
#include <boost/config.hpp>
#if __cplusplus >= 201103L || defined(BOOST_MSVC)
#include <utility> //for std::swap (C++11)
#else
#include <algorithm> //for std::swap (C++98)
#endif
#include <cstddef> //for std::size_t
namespace boost_swap_impl

13
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,13 @@
# Copyright 2018, 2019 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits Boost::throw_exception)
endif()
add_subdirectory(swap)

View File

@@ -55,10 +55,12 @@ compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ;
compile-fail explicit_operator_bool_compile_fail_delete.cpp ;
compile-fail explicit_operator_bool_compile_fail_shift.cpp ;
compile ignore_unused_test.cpp : <toolset>gcc-4.8:<cxxflags>"-Wunused-variable -Wunused-local-typedefs -Werror"
<toolset>gcc:<cxxflags>"-Wunused-variable -Werror"
<toolset>clang:<cxxflags>"-Wunused-variable -Werror"
<toolset>msvc:<cxxflags>"/we4100 /we4101" ;
compile ignore_unused_test.cpp
: <warnings>extra
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>msvc:<warnings-as-errors>on ;
run sp_typeinfo_test.cpp ;
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
@@ -75,6 +77,13 @@ run lightweight_test_gt_ge_test.cpp ;
run lightweight_test_eq_nullptr.cpp ;
run lightweight_test_test3.cpp ;
run lightweight_test_test4.cpp ;
run lightweight_test_test5.cpp
: : :
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
run-fail lightweight_test_all_eq_test.cpp ;
run-fail lightweight_test_all_with_fail.cpp ;
@@ -91,13 +100,15 @@ run-fail lightweight_test_fail8.cpp ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp ;
run-fail lightweight_test_fail11.cpp : ;
run-fail lightweight_test_fail12.cpp ;
run-fail lightweight_test_lt_fail.cpp ;
run-fail lightweight_test_le_fail.cpp ;
run-fail lightweight_test_gt_fail.cpp ;
run-fail lightweight_test_ge_fail.cpp ;
run lightweight_test_bool.cpp ;
run is_same_test.cpp ;
run typeinfo_test.cpp ;
@@ -106,9 +117,12 @@ run typeinfo_test.cpp : : : <rtti>off : typeinfo_test_no_rtti ;
run iterator_test.cpp ;
run detail_iterator_test.cpp ;
run demangle_test.cpp : : : <test-info>always_show_run_output ;
run demangle_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
run scoped_enum.cpp ;
@@ -145,6 +159,8 @@ run alloc_construct_test.cpp ;
run alloc_construct_throws_test.cpp ;
run alloc_construct_cxx11_test.cpp ;
run nvp_test.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
@@ -153,8 +169,10 @@ run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run uncaught_exceptions.cpp : : : <exception-handling>on ;
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
run uncaught_exceptions.cpp
: : : <exception-handling>on ;
run uncaught_exceptions_np.cpp
: : : <exception-handling>on ;
run no_exceptions_support_test.cpp ;
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void f0()

View File

@@ -7,7 +7,7 @@
//
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined( BOOST_NO_CXX11_NULLPTR )

View File

@@ -20,7 +20,7 @@
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{

View File

@@ -22,7 +22,7 @@
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{

View File

@@ -0,0 +1,17 @@
# Copyright 2018, 2019 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -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)
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if_c;
using boost::lazy_enable_if_c;

View File

@@ -14,7 +14,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::lazy_enable_if;
using boost::lazy_disable_if;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;

View File

@@ -13,7 +13,7 @@
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::is_arithmetic;

View File

@@ -13,7 +13,7 @@
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::is_arithmetic;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if_has_type;
using boost::enable_if_c;

View File

@@ -18,7 +18,7 @@
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/utility/explicit_operator_bool.hpp>
namespace {

View File

@@ -0,0 +1,63 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/lightweight_test.hpp>
#include <vector>
int main()
{
BOOST_TEST( BOOST_TEST( true ) );
BOOST_TEST_NOT( BOOST_TEST( false ) );
BOOST_TEST( BOOST_TEST_NOT( false ) );
BOOST_TEST_NOT( BOOST_TEST_NOT( true ) );
BOOST_TEST( BOOST_TEST_EQ( 1, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_EQ( 1, 2 ) );
BOOST_TEST( BOOST_TEST_NE( 1, 2 ) );
BOOST_TEST_NOT( BOOST_TEST_NE( 1, 1 ) );
BOOST_TEST( BOOST_TEST_LT( 1, 2 ) );
BOOST_TEST_NOT( BOOST_TEST_LT( 1, 1 ) );
BOOST_TEST( BOOST_TEST_LE( 1, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_LE( 2, 1 ) );
BOOST_TEST( BOOST_TEST_GT( 2, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_GT( 1, 1 ) );
BOOST_TEST( BOOST_TEST_GE( 1, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_GE( 1, 2 ) );
BOOST_TEST( BOOST_TEST_CSTR_EQ( "1", "1" ) );
BOOST_TEST_NOT( BOOST_TEST_CSTR_EQ( "1", "2" ) );
BOOST_TEST( BOOST_TEST_CSTR_NE( "1", "2" ) );
BOOST_TEST_NOT( BOOST_TEST_CSTR_NE( "1", "1" ) );
std::vector<int> v1;
v1.push_back( 1 );
std::vector<int> v2;
BOOST_TEST( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v1.begin(), v1.end()) );
BOOST_TEST_NOT( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v2.begin(), v2.end()) );
BOOST_TEST( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v1.begin(), v1.end(), boost::detail::lw_test_eq()) );
BOOST_TEST_NOT( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v2.begin(), v2.end(), boost::detail::lw_test_eq()) );
int const * p = 0;
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
int x = 0;
p = &x;
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
return boost::report_errors() == 14? 0: 1;
}

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
struct X
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
struct X
{

View File

@@ -9,7 +9,7 @@
//
#include <vector>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
struct X
{

View File

@@ -0,0 +1,19 @@
//
// Test that BOOST_TEST_EQ doesn't emit sign compare warnings
//
// Copyright 2019 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 <boost/core/lightweight_test.hpp>
int main()
{
BOOST_TEST_EQ(1, 1u);
BOOST_TEST_EQ(~0u, -1);
return boost::report_errors();
}

46
test/nvp_test.cpp Normal file
View File

@@ -0,0 +1,46 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/nvp.hpp>
#include <boost/core/lightweight_test.hpp>
void test()
{
const char* n = "name";
int v = 1;
boost::nvp<int> p(n, v);
BOOST_TEST_EQ(p.name(), n);
BOOST_TEST_EQ(p.value(), 1);
BOOST_TEST_EQ(&p.value(), &v);
}
void test_factory()
{
const char* n = "name";
int v = 1;
boost::nvp<int> p = boost::make_nvp(n, v);
BOOST_TEST_EQ(p.name(), n);
BOOST_TEST_EQ(p.value(), 1);
BOOST_TEST_EQ(&p.value(), &v);
}
void test_macro()
{
int v = 1;
boost::nvp<int> p = BOOST_NVP(v);
BOOST_TEST_CSTR_EQ(p.name(), "v");
BOOST_TEST_EQ(p.value(), 1);
BOOST_TEST_EQ(&p.value(), &v);
}
int main()
{
test();
test_factory();
test_macro();
return boost::report_errors();
}

View File

@@ -9,7 +9,7 @@
#include <boost/ref.hpp>
#include <boost/core/is_same.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
namespace {

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/ref.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void f0()

View File

@@ -7,7 +7,7 @@
// see 'ref_ct_test.cpp' for compile-time part
#include <boost/ref.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
namespace {
using namespace boost;

View File

@@ -11,7 +11,7 @@
#define BOOST_ALLOW_DEPRECATED_HEADERS
#include <boost/detail/sp_typeinfo.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
int main()

11
test/swap/CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
# Copyright 2018, 2019 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core)
endif()

View File

@@ -7,65 +7,31 @@
# bring in rules for testing
import testing ;
local compile_tests =
root_header_1.cpp
root_header_2.cpp
lib_header_1.cpp
lib_header_2.cpp
mixed_headers_1.cpp
mixed_headers_2.cpp
;
compile swap_root_header_1.cpp ;
compile swap_root_header_2.cpp ;
compile swap_lib_header_1.cpp ;
compile swap_lib_header_2.cpp ;
compile swap_mixed_headers_1.cpp ;
compile swap_mixed_headers_2.cpp ;
local compile_fail_tests =
const_wrapper_fail.cpp ;
compile-fail swap_const_wrapper_fail.cpp ;
local run_tests =
primitive.cpp
specialized_in_boost.cpp
specialized_in_global.cpp
specialized_in_other.cpp
specialized_in_std.cpp
specialized_in_boost_and_other.cpp
std_bitset.cpp
std_dateorder.cpp
std_string.cpp
std_typeinfo_ptr.cpp
std_vector_of_boost.cpp
std_vector_of_global.cpp
std_vector_of_other.cpp
no_ambiguity_in_boost.cpp
array_of_array_of_class.cpp
array_of_array_of_int.cpp
array_of_class.cpp
array_of_int.cpp
array_of_template.cpp
;
rule test_all
{
local all_rules ;
local file ;
for file in $(compile_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ compile $(file) : : "swap-$(test_name)" ] ;
}
for file in $(compile_fail_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ compile-fail $(file) : : "swap-$(test_name)" ] ;
}
for file in $(run_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ run $(file) : : : : "swap-$(test_name)" ] ;
}
#ECHO All rules: $(all_rules) ;
return $(all_rules) ;
}
test-suite core/swap : [ test_all r ] ;
run swap_primitive.cpp ;
run swap_specialized_in_boost.cpp ;
run swap_specialized_in_global.cpp ;
run swap_specialized_in_other.cpp ;
run swap_specialized_in_std.cpp ;
run swap_specialized_in_boost_and_other.cpp ;
run swap_std_bitset.cpp ;
run swap_std_dateorder.cpp ;
run swap_std_string.cpp ;
run swap_std_typeinfo_ptr.cpp ;
run swap_std_vector_of_boost.cpp ;
run swap_std_vector_of_global.cpp ;
run swap_std_vector_of_other.cpp ;
run swap_no_ambiguity_in_boost.cpp ;
run swap_array_of_array_of_class.cpp ;
run swap_array_of_array_of_int.cpp ;
run swap_array_of_class.cpp ;
run swap_array_of_int.cpp ;
run swap_array_of_template.cpp ;