Compare commits

..

36 Commits

Author SHA1 Message Date
Marshall Clow
375382e1e6 Merge pull request #67 from Kojoley/patch-1
Cease dependence on ContainerHash
2021-06-23 07:42:12 -07:00
Nikita Kniazev
6cca23a63a Cease dependence on ContainerHash
by local `hash_range` forward declaration
2021-06-20 19:34:05 +03:00
Peter Dimov
9ad7e51912 Update CMakeLists.txt 2021-06-10 00:45:51 +03:00
Andrey Semashev
601f80e8c1 Merge pull request #75 from Kojoley/feature/result_of-variadic-templates
Use variadic templates in result_of
2021-04-22 23:12:34 +03:00
Daniel Frey
c960bef6ef Merge pull request #76 from vahtis/develop
Workaround for Oracle Developer Studio
2021-03-25 16:58:37 +01:00
vahtis
6ab27d5689 Workaround for Oracle Developer Studio
Oracle Developer Studio needs same workaround as VIsual Studio
2021-03-25 11:32:37 +02:00
Nikita Kniazev
3e2f0199cf Use variadic templates in result_of 2021-03-08 04:25:46 +03:00
Marshall Clow
9c2aa8d193 Revert "Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73"
This reverts commit 601fc9371f.
2021-03-01 16:50:14 -08:00
Marshall Clow
601fc9371f Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73 2021-03-01 06:52:49 -08:00
Andrey Semashev
7aafdf92a0 [skip ci] Merge pull request #71 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 11:18:10 +03:00
Edward Diener
a7570d7608 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 22:19:49 -05:00
Peter Dimov
37168a3f4b Use address-model=32 for msvc-9.0, 10.0, 11.0 2020-10-12 00:01:10 +03:00
Glen Fernandes
e56171989a Merge pull request #69 from giomasce-throwaway/develop
Fix copyright headers.
2020-10-11 11:48:14 -04:00
Giovanni Mascellani
f00a5bf0d3 Fix copyright headers. 2020-10-11 17:35:14 +02:00
Andrey Semashev
a4feaf4f24 Merge pull request #66 from boostorg/feature/value-init
Add a new value_init test, change implementation to not depend on TypeTraits
2020-05-27 12:51:45 +03:00
Peter Dimov
688628f764 Add test/value_init_test3 2020-05-26 00:39:51 +03:00
Peter Dimov
8faf831bd1 memset data_ instead of *this 2020-05-25 23:50:35 +03:00
Peter Dimov
25cb7aa122 Use a base class to apply the memset workaround to avoid dependency on TypeTraits 2020-05-25 05:09:36 +03:00
Peter Dimov
0ae5cebc7f Add value_init_test2.cpp, which tests the cases from value_init_workaround_test 2020-05-25 04:44:29 +03:00
Andrey Semashev
1caa002121 Added gcc 10 build jobs to Travis CI. 2020-05-22 18:46:41 +03:00
Andrey Semashev
691f3238d7 Use 20 instead of 2a to refer to C++20 in Travis CI. 2020-05-05 23:12:01 +03:00
Andrey Semashev
8b6da499a3 Added clang-10 jobs to Travis CI. 2020-05-05 23:02:58 +03:00
Glen Fernandes
6e6d0777e8 Merge pull request #64 from glenfe/develop
Update to Operators constexpr support
2020-04-12 13:33:17 -04:00
Glen Fernandes
64fffa0f97 Simplify BOOST_OPERATORS_CONSTEXPR definition 2020-04-12 13:03:30 -04:00
Glen Fernandes
5da340a2a4 Rename BOOST_OPS_CONSTEXPR to BOOST_OPERATORS_CONSTEXPR 2020-04-12 13:03:22 -04:00
Glen Fernandes
9a4cff038b Move constexpr operators test to separate test 2020-04-12 13:03:18 -04:00
Marshall Clow
0c059a50ad Merge pull request #63 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74. Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost conf…
2020-04-12 09:49:06 -07:00
Daniel Frey
bdc5b5cf3a Merge pull request #55 from tonyelewis/add-constexpr-support
Add constexpr to operators (w/ basic docs, tests)
2020-04-12 13:07:24 +02:00
Glen Fernandes
86e7caefea Update CMakeLists.txt 2020-04-11 14:14:33 -04:00
Tony Lewis
7953ba56ba Update tests to run constexpr on newer MSVCs 2020-04-11 18:39:15 +01:00
Tony Lewis
46f72656b3 Remove constexpr from all but the comparison ops 2020-04-11 18:31:15 +01:00
Tony Lewis
e3a2a06011 Re-add constexpr support for newer MSVC versions 2020-04-11 18:30:24 +01:00
Edward Diener
a4752e066d Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-24 01:39:51 -04:00
Tony Lewis
6b62dcc504 Completely remove constexpr for MSVC 2018-12-24 07:02:31 +00:00
Tony Lewis
91ebdcd1dd Remove C++14 constexpr due to MSVC/GCC problems 2018-12-22 15:52:13 +00:00
Tony Lewis
e8d2b2ba76 Add constexpr to operators (w/ basic docs, tests) 2018-12-21 10:28:22 +00:00
23 changed files with 703 additions and 149 deletions

View File

@@ -136,6 +136,17 @@ matrix:
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- os: linux
dist: bionic
compiler: gcc-10
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20
addons:
apt:
packages:
- g++-10
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
# clang, Linux
- os: linux
dist: trusty
@@ -293,17 +304,31 @@ matrix:
- os: linux
dist: xenial
compiler: clang-libc++
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
compiler: clang-10
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20
addons:
apt:
packages:
- clang-9
- libc++-9-dev
- libc++abi-9-dev
- clang-10
- libstdc++-9-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
- os: linux
dist: xenial
compiler: clang-libc++
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20 CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
addons:
apt:
packages:
- clang-10
- libc++-10-dev
- libc++abi-10-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
# clang, OS X

View File

@@ -3,12 +3,9 @@
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://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.20)
cmake_minimum_required(VERSION 3.5)
project(BoostUtility LANGUAGES CXX)
project(boost_utility VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_utility INTERFACE)
add_library(Boost::utility ALIAS boost_utility)
@@ -18,8 +15,8 @@ target_include_directories(boost_utility INTERFACE include)
target_link_libraries(boost_utility
INTERFACE
Boost::config
Boost::container_hash
Boost::core
Boost::io
Boost::preprocessor
Boost::static_assert
Boost::throw_exception

View File

@@ -15,9 +15,10 @@ branches:
environment:
matrix:
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-14.0
- TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-14.1

View File

@@ -1,6 +1,6 @@
[/
/ Copyright (c) 2008 Howard Hinnant
/ Copyright (c) 2009-20012 Vicente J. Botet Escriba
/ Copyright (c) 2009-2012 Vicente J. Botet Escriba
/
/ 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)

View File

@@ -100,7 +100,7 @@ struct call_traits<T&>
typedef T& param_type; // hh removed const
};
#if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 )
#if BOOST_WORKAROUND( BOOST_BORLANDC, < 0x5A0 )
// these are illegal specialisations; cv-qualifies applied to
// references have no effect according to [8.3.2p1],
// C++ Builder requires them though as it treats cv-qualified

View File

@@ -109,6 +109,15 @@
# pragma warning( disable : 4284 ) // complaint about return type of
#endif // operator-> not begin a UDT
// Define BOOST_OPERATORS_CONSTEXPR to be like BOOST_CONSTEXPR but empty under MSVC < v19.22
#if BOOST_WORKAROUND(BOOST_MSVC, < 1922)
#define BOOST_OPERATORS_CONSTEXPR
#elif defined __sun
#define BOOST_OPERATORS_CONSTEXPR
#else
#define BOOST_OPERATORS_CONSTEXPR BOOST_CONSTEXPR
#endif
// In this section we supply the xxxx1 and xxxx2 forms of the operator
// templates, which are explicitly targeted at the 1-type-argument and
// 2-type-argument operator forms, respectively.
@@ -132,34 +141,34 @@ template <typename T> class empty_base {};
template <class T, class U, class B = operators_detail::empty_base<T> >
struct less_than_comparable2 : B
{
friend bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
friend bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
friend bool operator>(const U& x, const T& y) { return y < x; }
friend bool operator<(const U& x, const T& y) { return y > x; }
friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
friend bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const U& x, const T& y) { return y < x; }
friend BOOST_OPERATORS_CONSTEXPR bool operator<(const U& x, const T& y) { return y > x; }
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
};
template <class T, class B = operators_detail::empty_base<T> >
struct less_than_comparable1 : B
{
friend bool operator>(const T& x, const T& y) { return y < x; }
friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
friend bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const T& x, const T& y) { return y < x; }
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
};
template <class T, class U, class B = operators_detail::empty_base<T> >
struct equality_comparable2 : B
{
friend bool operator==(const U& y, const T& x) { return x == y; }
friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const U& y, const T& x) { return x == y; }
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
};
template <class T, class B = operators_detail::empty_base<T> >
struct equality_comparable1 : B
{
friend bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
};
// A macro which produces "name_2left" from "name".
@@ -362,7 +371,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> )
template <class T, class U, class B = operators_detail::empty_base<T> >
struct equivalent2 : B
{
friend bool operator==(const T& x, const U& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const T& x, const U& y)
{
return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
}
@@ -371,7 +380,7 @@ struct equivalent2 : B
template <class T, class B = operators_detail::empty_base<T> >
struct equivalent1 : B
{
friend bool operator==(const T&x, const T&y)
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const T&x, const T&y)
{
return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
}
@@ -380,28 +389,28 @@ struct equivalent1 : B
template <class T, class U, class B = operators_detail::empty_base<T> >
struct partially_ordered2 : B
{
friend bool operator<=(const T& x, const U& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const U& y)
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const U& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const U& y)
{ return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
friend bool operator>(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const U& x, const T& y)
{ return y < x; }
friend bool operator<(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<(const U& x, const T& y)
{ return y > x; }
friend bool operator<=(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const U& x, const T& y)
{ return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
friend bool operator>=(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const U& x, const T& y)
{ return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
};
template <class T, class B = operators_detail::empty_base<T> >
struct partially_ordered1 : B
{
friend bool operator>(const T& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const T& x, const T& y)
{ return y < x; }
friend bool operator<=(const T& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const T& y)
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const T& y)
{ return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
};

View File

@@ -22,7 +22,7 @@
# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
: conditional<
@@ -151,7 +151,7 @@ struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)>
: tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
@@ -177,7 +177,7 @@ struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), F
typedef R type;
};
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),

View File

@@ -0,0 +1,190 @@
// Boost result_of library
// Copyright Douglas Gregor 2004. Use, modification and
// distribution is 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)
// Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012.
// Use, modification and distribution is 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)
// For more information, see http://www.boost.org/libs/utility
#ifndef BOOST_RESULT_OF_HPP
# error Boost result_of - do not include this file!
#endif
template<typename F, typename... Args>
struct tr1_result_of<F(Args...)>
: conditional<
is_pointer<F>::value || is_member_function_pointer<F>::value
, boost::detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(Args...),
(boost::detail::result_of_has_result_type<F>::value)>
, boost::detail::tr1_result_of_impl<
F,
F(Args...),
(boost::detail::result_of_has_result_type<F>::value)> >::type { };
#ifdef BOOST_RESULT_OF_USE_DECLTYPE
template<typename F, typename... Args>
struct result_of<F(Args...)>
: detail::cpp0x_result_of<F(Args...)> { };
#endif // BOOST_RESULT_OF_USE_DECLTYPE
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
template<typename F, typename... Args>
struct result_of<F(Args...)>
: conditional<detail::result_of_has_result_type<F>::value || detail::result_of_has_result<F>::value,
tr1_result_of<F(Args...)>,
detail::cpp0x_result_of<F(Args...)> >::type { };
#endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
#if defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
namespace detail {
template<typename F, typename... Args>
struct cpp0x_result_of<F(Args...)>
: conditional<
is_member_function_pointer<F>::value
, detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(Args...), false
>
, detail::cpp0x_result_of_impl<
F(Args...)
>
>::type
{};
#ifdef BOOST_NO_SFINAE_EXPR
template<typename F>
struct result_of_callable_fun_2;
template<typename R, typename... Args>
struct result_of_callable_fun_2<R(Args...)> {
R operator()(Args...) const;
typedef result_of_private_type const &(*pfn_t)(...);
operator pfn_t() const volatile;
};
template<typename F>
struct result_of_callable_fun
: result_of_callable_fun_2<F>
{};
template<typename F>
struct result_of_callable_fun<F *>
: result_of_callable_fun_2<F>
{};
template<typename F>
struct result_of_select_call_wrapper_type
: conditional<
is_class<typename remove_reference<F>::type>::value,
result_of_wrap_callable_class<F>,
type_identity<result_of_callable_fun<typename remove_cv<typename remove_reference<F>::type>::type> >
>::type
{};
template<typename F, typename... Args>
struct result_of_is_callable {
typedef typename result_of_select_call_wrapper_type<F>::type wrapper_t;
static const bool value = (
sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
(boost::declval<wrapper_t>()(boost::declval<Args>()...), result_of_weird_type())
))
);
typedef integral_constant<bool, value> type;
};
template<typename F, typename... Args>
struct cpp0x_result_of_impl<F(Args...), true>
: lazy_enable_if<
result_of_is_callable<F, Args...>
, cpp0x_result_of_impl<F(Args...), false>
>
{};
template<typename F, typename... Args>
struct cpp0x_result_of_impl<F(Args...), false>
{
typedef decltype(
boost::declval<F>()(
boost::declval<Args>()...
)
) type;
};
#else // BOOST_NO_SFINAE_EXPR
template<typename F, typename... Args>
struct cpp0x_result_of_impl<F(Args...),
typename result_of_always_void<decltype(
boost::declval<F>()(
boost::declval<Args>()...
)
)>::type> {
typedef decltype(
boost::declval<F>()(
boost::declval<Args>()...
)
) type;
};
#endif // BOOST_NO_SFINAE_EXPR
} // namespace detail
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
template<typename F, typename... Args>
struct result_of<F(Args...)>
: tr1_result_of<F(Args...)> { };
#endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
namespace detail {
template<typename R, typename FArgs, typename... Args>
struct tr1_result_of_impl<R (*)(Args...), FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename... Args>
struct tr1_result_of_impl<R (&)(Args...), FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...), FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...) const, FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...) volatile, FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...) const volatile, FArgs, false>
{
typedef R type;
};
}

View File

@@ -10,13 +10,6 @@
#define BOOST_RESULT_OF_HPP
#include <boost/config.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_pointer.hpp>
@@ -29,6 +22,20 @@
#include <boost/type_traits/integral_constant.hpp>
#include <boost/core/enable_if.hpp>
#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
# undef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
# define BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
#endif
#ifdef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/iteration/iterate.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
# include <boost/preprocessor/repetition/enum_shifted_params.hpp>
# include <boost/preprocessor/facilities/intercept.hpp>
#endif
#ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 16
#endif
@@ -217,8 +224,12 @@ struct tr1_result_of_impl<F, FArgs, false>
} // end namespace detail
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
#include BOOST_PP_ITERATE()
#ifndef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
# include <boost/utility/detail/result_of_variadic.hpp>
#else
# define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
# include BOOST_PP_ITERATE()
#endif
#if 0
// inform dependency trackers, as they can't see through macro includes

View File

@@ -23,7 +23,6 @@
#include <boost/io/ostream_put.hpp>
#include <boost/utility/string_view_fwd.hpp>
#include <boost/throw_exception.hpp>
#include <boost/container_hash/hash_fwd.hpp>
#include <cstddef>
#include <stdexcept>
@@ -652,6 +651,9 @@ namespace boost {
}
#endif
// Forward declaration of Boost.ContainerHash function
template <class It> std::size_t hash_range(It, It);
template <class charT, class traits>
std::size_t hash_value(basic_string_view<charT, traits> s) {
return boost::hash_range(s.begin(), s.end());

View File

@@ -1,4 +1,5 @@
// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
// Copyright 2020 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -21,15 +22,10 @@
// issues, by clearing the bytes of T, before constructing the T object it
// contains. More details on these issues are at libs/utility/value_init.htm
#include <boost/aligned_storage.hpp>
#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
#include <boost/detail/workaround.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/swap.hpp>
#include <cstring>
#include <new>
#include <cstddef>
#ifdef BOOST_MSVC
#pragma warning(push)
@@ -60,92 +56,58 @@
namespace boost {
namespace detail {
struct zero_init
{
zero_init()
{
}
zero_init( void * p, std::size_t n )
{
std::memset( p, 0, n );
}
};
} // namespace detail
template<class T>
class initialized
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
: detail::zero_init
#endif
{
private :
struct wrapper
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
typename
#endif
remove_const<T>::type data;
private:
BOOST_GPU_ENABLED
wrapper()
:
data()
{
}
BOOST_GPU_ENABLED
wrapper(T const & arg)
:
data(arg)
{
}
};
mutable
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
typename
#endif
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
BOOST_GPU_ENABLED
wrapper * wrapper_address() const
{
return static_cast<wrapper *>( static_cast<void*>(&x));
}
T data_;
public :
BOOST_GPU_ENABLED
initialized()
{
initialized():
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
std::memset(&x, 0, sizeof(x));
zero_init( &const_cast< char& >( reinterpret_cast<char const volatile&>( data_ ) ), sizeof( data_ ) ),
#endif
new (wrapper_address()) wrapper();
data_()
{
}
BOOST_GPU_ENABLED
initialized(initialized const & arg)
explicit initialized(T const & arg): data_( arg )
{
new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
}
BOOST_GPU_ENABLED
explicit initialized(T const & arg)
{
new (wrapper_address()) wrapper(arg);
}
BOOST_GPU_ENABLED
initialized & operator=(initialized const & arg)
{
// Assignment is only allowed when T is non-const.
BOOST_STATIC_ASSERT( ! is_const<T>::value );
*wrapper_address() = static_cast<wrapper const &>(*(arg.wrapper_address()));
return *this;
}
BOOST_GPU_ENABLED
~initialized()
{
wrapper_address()->wrapper::~wrapper();
}
BOOST_GPU_ENABLED
T const & data() const
{
return wrapper_address()->data;
return data_;
}
BOOST_GPU_ENABLED
T& data()
{
return wrapper_address()->data;
return data_;
}
BOOST_GPU_ENABLED
@@ -157,13 +119,13 @@ class initialized
BOOST_GPU_ENABLED
operator T const &() const
{
return wrapper_address()->data;
return data_;
}
BOOST_GPU_ENABLED
operator T&()
{
return wrapper_address()->data;
return data_;
}
} ;

View File

@@ -13,7 +13,8 @@
"Memory",
"Miscellaneous",
"Patterns"
]
],
"cxxstd": "03"
},
{
"key": "utility/call_traits",
@@ -25,7 +26,8 @@
"documentation": "call_traits.htm",
"category": [
"Generic"
]
],
"cxxstd": "03"
},
{
"key": "utility/compressed_pair",
@@ -38,7 +40,8 @@
"category": [
"Data",
"Patterns"
]
],
"cxxstd": "03"
},
{
"key": "utility/identity_type",
@@ -53,7 +56,8 @@
],
"maintainers": [
"Lorenzo Caminiti <lorcaminiti -at- gmail.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/in_place_factories",
@@ -65,7 +69,8 @@
"documentation": "in_place_factories.html",
"category": [
"Generic"
]
],
"cxxstd": "03"
},
{
"key": "utility/operators",
@@ -83,7 +88,8 @@
],
"maintainers": [
"Daniel Frey <d.frey -at- gmx.de>"
]
],
"cxxstd": "03"
},
{
"key": "utility/result_of",
@@ -96,7 +102,8 @@
"authors": "",
"maintainers": [
"Daniel Walker <daniel.j.walker -at- gmail.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/string_ref",
@@ -109,7 +116,8 @@
"authors": "Marshall Clow",
"maintainers": [
"Marshall Clow <marshall -at- idio.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/value_initialized",
@@ -121,6 +129,7 @@
"documentation": "value_init.htm",
"category": [
"Miscellaneous"
]
],
"cxxstd": "03"
}
]

View File

@@ -454,7 +454,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
</caption>
<tr>
<td colspan="3">
<td colspan="4">
<table align="center" border="1">
<caption>
<em>Key</em>
@@ -482,6 +482,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<th>Supplied Operations</th>
<th>Requirements</th>
<th>Propagates <code>constexpr</code>?</th>
</tr>
<tr>
@@ -496,6 +498,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; t1</code>.<br>
Return convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -513,6 +518,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; u</code>. <code>t &gt; u</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -524,6 +532,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t == t1</code>.<br>
Return convertible to <code>bool</code>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -537,6 +548,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t == u</code>.<br>
Return convertible to <code>bool</code>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -548,6 +562,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp += t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -560,6 +576,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp += u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -572,6 +590,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp -= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -584,6 +604,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp -= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -594,6 +616,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(u); temp -= t</code>.<br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@@ -606,6 +630,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp *= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -619,6 +645,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp *= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -630,6 +658,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp /= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -641,6 +671,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp /= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -651,6 +683,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(u); temp /= t</code>.<br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@@ -662,6 +696,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp %= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -673,6 +709,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp %= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -683,6 +721,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(u); temp %= t</code>.<br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@@ -694,6 +734,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp |= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -706,6 +748,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp |= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -717,6 +761,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &amp;= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -729,6 +775,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &amp;= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -740,6 +788,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp ^= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -752,6 +802,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp ^= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -762,6 +814,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); ++t</code><br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@@ -772,6 +826,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); --t;</code><br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@@ -784,6 +840,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &lt;&lt;= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -796,6 +854,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &lt;&lt;= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -808,6 +868,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &gt;&gt;= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -820,6 +882,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &gt;&gt;= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@@ -831,6 +895,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; t1</code>.<br>
Return convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -842,6 +909,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; u</code>. <code>t &gt; u</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -856,6 +926,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; t1</code>. <code>t == t1</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@@ -874,6 +947,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
u</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
</table>

View File

@@ -21,6 +21,7 @@ run compressed_pair_final_test.cpp ;
run iterators_test.cpp ;
run operators_test.cpp ;
compile operators_constexpr_test.cpp ;
compile result_of_test.cpp ;
@@ -35,6 +36,8 @@ run string_view_test2.cpp ;
run string_view_test_io.cpp ;
run value_init_test.cpp ;
run value_init_test2.cpp ;
run value_init_test3.cpp ;
run value_init_workaround_test.cpp ;
run initialized_test.cpp ;
compile-fail value_init_test_fail1.cpp ;

View File

@@ -376,7 +376,7 @@ void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>:
reference r = t;
const_reference cr = t;
reference r2 = r;
#ifndef __BORLANDC__
#ifndef BOOST_BORLANDC
// C++ Builder buglet:
const_reference cr2 = r;
#endif
@@ -393,7 +393,7 @@ void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>:
unused_variable(v3);
unused_variable(v4);
unused_variable(v5);
#ifndef __BORLANDC__
#ifndef BOOST_BORLANDC
unused_variable(r2);
unused_variable(cr2);
#endif

View File

@@ -0,0 +1,59 @@
/*
Copyright 2020 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/config.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && \
(!defined(BOOST_MSVC) || (BOOST_MSVC >= 1922))
#include <boost/operators.hpp>
#include <boost/static_assert.hpp>
namespace {
class Value
: boost::operators<Value> {
public:
BOOST_OPERATORS_CONSTEXPR explicit Value(int v)
: v_(v) { }
BOOST_OPERATORS_CONSTEXPR bool
operator<(const Value& x) const {
return v_ < x.v_;
}
BOOST_OPERATORS_CONSTEXPR bool
operator==(const Value& x) const {
return v_ == x.v_;
}
private:
int v_;
};
} // namespace
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) == Value(2)));
BOOST_STATIC_ASSERT(Value(1) != Value(2));
BOOST_STATIC_ASSERT(Value(1) < Value(2));
BOOST_STATIC_ASSERT(Value(1) <= Value(2));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) > Value(2)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) >= Value(2)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) == Value(1)));
BOOST_STATIC_ASSERT(Value(2) != Value(1));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) < Value(1)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) <= Value(1)));
BOOST_STATIC_ASSERT(Value(2) > Value(1));
BOOST_STATIC_ASSERT(Value(2) >= Value(1));
BOOST_STATIC_ASSERT(Value(1) == Value(1));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) != Value(1)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) < Value(1)));
BOOST_STATIC_ASSERT(Value(1) <= Value(1));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) > Value(1)));
BOOST_STATIC_ASSERT(Value(1) >= Value(1));
#endif

View File

@@ -50,9 +50,9 @@ namespace
void operator!() const;
public:
convertible_to_bool( const bool value ) : _value( value ) {}
convertible_to_bool( const bool value ) : _value( value ) {}
operator unspecified_bool_type() const
operator unspecified_bool_type() const
{ return _value ? &convertible_to_bool::_value : 0; }
};
@@ -64,12 +64,12 @@ namespace
, boost::shiftable<Wrapped1<T> >
{
public:
explicit Wrapped1( T v = T() ) : _value(v) {}
T value() const { return _value; }
explicit Wrapped1( T v = T() ) : _value(v) {}
T value() const { return _value; }
convertible_to_bool operator<(const Wrapped1& x) const
convertible_to_bool operator<(const Wrapped1& x) const
{ return _value < x._value; }
convertible_to_bool operator==(const Wrapped1& x) const
convertible_to_bool operator==(const Wrapped1& x) const
{ return _value == x._value; }
Wrapped1& operator+=(const Wrapped1& x)
@@ -92,8 +92,8 @@ namespace
{ _value <<= x._value; return *this; }
Wrapped1& operator>>=(const Wrapped1& x)
{ _value >>= x._value; return *this; }
Wrapped1& operator++() { ++_value; return *this; }
Wrapped1& operator--() { --_value; return *this; }
Wrapped1& operator++() { ++_value; return *this; }
Wrapped1& operator--() { --_value; return *this; }
private:
T _value;

View File

@@ -17,11 +17,12 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include <boost/core/lightweight_test.hpp>
#include <boost/config/workaround.hpp>
//
// Sample POD type
@@ -217,8 +218,8 @@ void check_initialized_value ( T const& y )
BOOST_TEST ( y == initializedValue ) ;
}
#ifdef __BORLANDC__
#if __BORLANDC__ == 0x582
#ifdef BOOST_BORLANDC
#if BOOST_BORLANDC == 0x582
void check_initialized_value( NonPOD const& )
{
// The initialized_value check is skipped for Borland 5.82

169
test/value_init_test2.cpp Normal file
View File

@@ -0,0 +1,169 @@
// Copyright 2010, Niels Dekker.
//
// 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)
//
// Test program for the boost::value_initialized<T> workaround.
//
// 17 June 2010 (Created) Niels Dekker
#include <boost/utility/value_init.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/workaround.hpp>
#include <iostream>
namespace
{
struct empty_struct
{
};
// A POD aggregate struct derived from an empty struct.
// Similar to struct Foo1 from Microsoft Visual C++ bug report 484295,
// "VC++ does not value-initialize members of derived classes without
// user-declared constructor", reported in 2009 by Sylvester Hesp:
// https://connect.microsoft.com/VisualStudio/feedback/details/484295
struct derived_struct: empty_struct
{
int data;
};
bool is_value_initialized(const derived_struct& arg)
{
return arg.data == 0;
}
class virtual_destructor_holder
{
public:
int i;
virtual ~virtual_destructor_holder()
{
}
};
bool is_value_initialized(const virtual_destructor_holder& arg)
{
return arg.i == 0;
}
// Equivalent to the Stats class from GCC Bug 33916,
// "Default constructor fails to initialize array members", reported in 2007 by
// Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
// and fixed for GCC 4.2.4.
class private_int_array_pair
{
friend bool is_value_initialized(const private_int_array_pair& arg);
private:
int first[12];
int second[12];
};
bool is_value_initialized(const private_int_array_pair& arg)
{
for ( unsigned i = 0; i < 12; ++i)
{
if ( (arg.first[i] != 0) || (arg.second[i] != 0) )
{
return false;
}
}
return true;
}
struct int_pair_struct
{
int first;
int second;
};
typedef int int_pair_struct::*ptr_to_member_type;
struct ptr_to_member_struct
{
ptr_to_member_type data;
};
bool is_value_initialized(const ptr_to_member_struct& arg)
{
return arg.data == 0;
}
template <typename T>
bool is_value_initialized(const T(& arg)[2])
{
return
is_value_initialized(arg[0]) &&
is_value_initialized(arg[1]);
}
template <typename T>
bool is_value_initialized(const boost::value_initialized<T>& arg)
{
return is_value_initialized(arg.data());
}
// Returns zero when the specified object is value-initializated, and one otherwise.
// Prints a message to standard output if the value-initialization has failed.
template <class T>
unsigned failed_to_value_initialized(const T& object, const char *const object_name)
{
if ( is_value_initialized(object) )
{
return 0u;
}
else
{
std::cout << "Note: Failed to value-initialize " << object_name << '.' << std::endl;
return 1u;
}
}
// A macro that passed both the name and the value of the specified object to
// the function above here.
#define FAILED_TO_VALUE_INITIALIZE(value) failed_to_value_initialized(value, #value)
// Equivalent to the dirty_stack() function from GCC Bug 33916,
// "Default constructor fails to initialize array members", reported in 2007 by
// Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
void dirty_stack()
{
unsigned char array_on_stack[4096];
for (unsigned i = 0; i < sizeof(array_on_stack); ++i)
{
array_on_stack[i] = 0x11;
}
}
}
int main()
{
#ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
std::cout << "BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED is defined.\n\n";
#endif
dirty_stack();
BOOST_TEST( is_value_initialized( boost::value_initialized<derived_struct>() ) );
BOOST_TEST( is_value_initialized( boost::value_initialized<virtual_destructor_holder[2]>() ) );
BOOST_TEST( is_value_initialized( boost::value_initialized<private_int_array_pair>() ) );
#if !BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1925) )
// Null pointers to data members are represented as -1 in MSVC, but
// value initialization sets them to all zero. The workaround employed
// by value_initialized<> is to memset the storage to all zero, which
// doesn't help.
BOOST_TEST( is_value_initialized( boost::value_initialized<ptr_to_member_struct>() ) );
#endif
return boost::report_errors();
}

40
test/value_init_test3.cpp Normal file
View File

@@ -0,0 +1,40 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/value_init.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if __cplusplus >= 201103L || ( defined(BOOST_MSVC) && BOOST_MSVC >= 1900 )
struct X
{
int a;
char b;
};
struct Y: boost::value_initialized<X>
{
char c = 42;
};
int main()
{
Y y;
BOOST_TEST_EQ( y.data().a, 0 );
BOOST_TEST_EQ( y.data().b, 0 );
BOOST_TEST_EQ( y.c, 42 );
return boost::report_errors();
}
#else
BOOST_PRAGMA_MESSAGE( "Skipping test because compiler doesn't support in-class member initializers" )
int main() {}
#endif

View File

@@ -13,7 +13,7 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@@ -13,7 +13,7 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@@ -13,7 +13,7 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif