forked from boostorg/core
Compare commits
32 Commits
boost-1.64
...
feature/cm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c17e33d6f2 | ||
|
|
d426b95281 | ||
|
|
dca0d13ca9 | ||
|
|
a88bbcc8ba | ||
|
|
c4f3e1acc0 | ||
|
|
69696c0cba | ||
|
|
283460b991 | ||
|
|
3a2c94df8c | ||
|
|
226ef58027 | ||
|
|
0f8b499bca | ||
|
|
a3f6d12b57 | ||
|
|
cccac1d631 | ||
|
|
6153eebc42 | ||
|
|
ab05c190be | ||
|
|
637b2ffaff | ||
|
|
43426067df | ||
|
|
f76116405d | ||
|
|
89b1792724 | ||
|
|
87dd2883b8 | ||
|
|
cba69f5e4c | ||
|
|
5eaa31e366 | ||
|
|
2d56d6f55b | ||
|
|
6fd649d7fd | ||
|
|
335aa4f396 | ||
|
|
26cab26e52 | ||
|
|
b805efd4fe | ||
|
|
80875a19b6 | ||
|
|
6ba388125e | ||
|
|
889502504d | ||
|
|
16c5503648 | ||
|
|
dc6003e26f | ||
|
|
46545326d8 |
8
CMakeLists.txt
Normal file
8
CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include(cmake/BoostVersion.cmake)
|
||||
set(BOOST_PROJECT_NAME core)
|
||||
|
||||
project(boost_${BOOST_PROJECT_NAME} VERSION ${BOOST_VERSION} LANGUAGES CXX)
|
||||
|
||||
include(cmake/default.cmake)
|
||||
1
cmake/BoostVersion.cmake
Normal file
1
cmake/BoostVersion.cmake
Normal file
@@ -0,0 +1 @@
|
||||
set(BOOST_VERSION 1.65.0)
|
||||
20
cmake/Jamfile
Normal file
20
cmake/Jamfile
Normal file
@@ -0,0 +1,20 @@
|
||||
# Update cmake files
|
||||
|
||||
install BoostVersion_ : ../../../BoostVersion.cmake : <location>. ;
|
||||
install default_ : ../../../cmake/default.cmake : <location>. ;
|
||||
|
||||
# Update dependencies
|
||||
|
||||
import path ;
|
||||
|
||||
path-constant LIBDIR : .. ;
|
||||
|
||||
actions boostdep-cmake
|
||||
{
|
||||
"$(LIBDIR)/../../dist/bin/boostdep" --cmake $(LIBDIR:B) > $(1)
|
||||
}
|
||||
|
||||
make dependencies.cmake : : @boostdep-cmake ;
|
||||
always dependencies.cmake ;
|
||||
|
||||
install dependencies_ : dependencies.cmake : <location>. ;
|
||||
103
cmake/default.cmake
Normal file
103
cmake/default.cmake
Normal file
@@ -0,0 +1,103 @@
|
||||
#
|
||||
# Default CMakeLists.txt contents for a Boost library
|
||||
#
|
||||
|
||||
# sources.cmake defines ${PROJECT_NAME}_SOURCES
|
||||
include(cmake/sources.cmake)
|
||||
|
||||
if("${${PROJECT_NAME}_SOURCES}" STREQUAL "")
|
||||
|
||||
# if no sources, this is a header-only library
|
||||
add_library(boost_${BOOST_PROJECT_NAME} INTERFACE)
|
||||
|
||||
# include directory
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
# a library that requires building
|
||||
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES})
|
||||
|
||||
# include directory
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# add namespaced alias
|
||||
add_library(boost::${BOOST_PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
|
||||
# set imported target name to the unqualified name, it will be namespaced
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY EXPORT_NAME ${BOOST_PROJECT_NAME})
|
||||
|
||||
# link to dependencies
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
function(boost_declare_dependency package type target)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${type} ${target})
|
||||
|
||||
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
|
||||
|
||||
find_dependency(${package} ${PROJECT_VERSION} EXACT)
|
||||
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
include(cmake/dependencies.cmake)
|
||||
|
||||
# target installation
|
||||
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
# header installation
|
||||
install(DIRECTORY include/ DESTINATION include)
|
||||
|
||||
# export target info to ${PROJECT_NAME}-targets.cmake, used by -config.cmake
|
||||
install(EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}-targets.cmake
|
||||
NAMESPACE boost::
|
||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||
)
|
||||
|
||||
# install -dependencies.cmake, used by -config.cmake
|
||||
|
||||
install(FILES cmake/dependencies.cmake
|
||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||
RENAME ${PROJECT_NAME}-dependencies.cmake
|
||||
)
|
||||
|
||||
# write ${PROJECT_NAME}-config.cmake
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "
|
||||
include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-targets.cmake)
|
||||
include(CMakeFindDependencyMacro)
|
||||
function(boost_declare_dependency package type target)
|
||||
find_dependency(\${package} ${PROJECT_VERSION} EXACT)
|
||||
endfunction()
|
||||
include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-dependencies.cmake)
|
||||
")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# write ${PROJECT_NAME}-config-version.cmake
|
||||
write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
# install -config, -config-version
|
||||
install(FILES
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||
)
|
||||
4
cmake/dependencies.cmake
Normal file
4
cmake/dependencies.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
# Generated file. Do not edit.
|
||||
|
||||
boost_declare_dependency(boost_assert INTERFACE boost::assert)
|
||||
boost_declare_dependency(boost_config INTERFACE boost::config)
|
||||
0
cmake/sources.cmake
Normal file
0
cmake/sources.cmake
Normal file
@@ -49,6 +49,7 @@ criteria for inclusion is that the utility component be:
|
||||
[include no_exceptions_support.qbk]
|
||||
[include noncopyable.qbk]
|
||||
[include null_deleter.qbk]
|
||||
[include pointer_traits.qbk]
|
||||
[include ref.qbk]
|
||||
[include scoped_enum.qbk]
|
||||
[include swap.qbk]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[/
|
||||
Copyright 2010, 2011 Beman Dawes
|
||||
Copyright 2013 Ion Gaztanaga
|
||||
Copyright 2014 Peter Dimov
|
||||
Copyright 2014, 2017 Peter Dimov
|
||||
Copyright 2017 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@@ -36,6 +37,10 @@ When using `lightweight_test.hpp`, *do not forget* to
|
||||
#define BOOST_ERROR(message) /*unspecified*/
|
||||
#define BOOST_TEST_EQ(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_NE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_LT(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_LE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_GT(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_GE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */
|
||||
@@ -89,7 +94,7 @@ Increases error count and outputs a message containing
|
||||
BOOST_TEST_EQ(expr1, expr2)
|
||||
``
|
||||
|
||||
If `expr1 != expr2` increases the error count and outputs a
|
||||
If `expr1 == expr2` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
@@ -100,7 +105,51 @@ message containing both expressions.
|
||||
BOOST_TEST_NE(expr1, expr2)
|
||||
``
|
||||
|
||||
If `expr1 == expr2` increases the error count and outputs a
|
||||
If `expr1 != expr2` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_LT]
|
||||
|
||||
``
|
||||
BOOST_TEST_LT(expr1, expr2)
|
||||
``
|
||||
|
||||
If `expr1 < expr2` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_LE]
|
||||
|
||||
``
|
||||
BOOST_TEST_LE(expr1, expr2)
|
||||
``
|
||||
|
||||
If `expr1 <= expr2` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_GT]
|
||||
|
||||
``
|
||||
BOOST_TEST_GT(expr1, expr2)
|
||||
``
|
||||
|
||||
If `expr1 > expr2` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_GE]
|
||||
|
||||
``
|
||||
BOOST_TEST_GE(expr1, expr2)
|
||||
``
|
||||
|
||||
If `expr1 >= expr2` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
@@ -111,7 +160,7 @@ message containing both expressions.
|
||||
BOOST_TEST_CSTR_EQ(expr1, expr2)
|
||||
``
|
||||
|
||||
Specialization of BOOST_TEST_EQ which interprets expr1 and expr2 as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) != 0`, increase the error count and output a message containing both expressions.
|
||||
Specialization of `BOOST_TEST_EQ` which interprets `expr1` and `expr2` as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) != 0`, increase the error count and output a message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -121,7 +170,7 @@ Specialization of BOOST_TEST_EQ which interprets expr1 and expr2 as pointers to
|
||||
BOOST_TEST_CSTR_NE(expr1, expr2)
|
||||
``
|
||||
|
||||
Specialization of BOOST_TEST_NE which interprets expr1 and expr2 as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) == 0`, increase the error count and output a message containing both expressions.
|
||||
Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) == 0`, increase the error count and output a message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
141
doc/pointer_traits.qbk
Normal file
141
doc/pointer_traits.qbk
Normal file
@@ -0,0 +1,141 @@
|
||||
[/
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:pointer_traits pointer_traits]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/pointer_traits.hpp> provides the class template
|
||||
`boost::pointer_traits` to facilitate use of pointer-like types. The C++11
|
||||
standard library introduced `std::pointer_traits` along with an allocator
|
||||
model which supported pointer-like types in addition to plain raw pointers.
|
||||
This implementation also supports C++98, and adds additional functionality
|
||||
for obtaining raw pointers from pointers.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following function template obtains a raw pointer from a pointer and is
|
||||
well defined when the pointer aliases storage that has no object constructed
|
||||
in it.
|
||||
|
||||
```
|
||||
template<class T>
|
||||
inline typename boost::pointer_traits<T>::element_type*
|
||||
to_raw_pointer(T v) noexcept
|
||||
{
|
||||
return boost::pointer_traits<T>::to_address(v);
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
template<class T> struct pointer_traits {
|
||||
typedef T pointer;
|
||||
typedef ``['see below]`` element_type;
|
||||
typedef ``['see below]`` difference_type;
|
||||
|
||||
template<class U> struct rebind_to { typedef ``['see below]`` type; };
|
||||
template<class U> using rebind = typename rebind_to<U>::type;
|
||||
|
||||
static pointer pointer_to(``['see below]`` v);
|
||||
static element_type* to_address(pointer v) noexcept;
|
||||
};
|
||||
|
||||
template<class T> struct pointer_traits<T*> {
|
||||
typedef T* pointer;
|
||||
typedef T element_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
template<class U> struct rebind_to { typedef U* type; };
|
||||
template<class U> using rebind = typename rebind_to<U>::type;
|
||||
|
||||
static pointer pointer_to(``['see below]`` v) noexcept;
|
||||
static element_type* to_address(pointer v) noexcept;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
[section Member types]
|
||||
|
||||
[variablelist
|
||||
[[`typedef` ['see below] `element_type;`]
|
||||
[[variablelist
|
||||
[[Type]
|
||||
[`T::element_type` if such a type exists; otherwise `U` if `T` is a
|
||||
class template instantiation of the form `Pointer<U, Args>`, where
|
||||
`Args` is zero or more type arguments; otherwise the specialization
|
||||
is ill-formed.]]]]]
|
||||
[[`typedef` ['see below] `difference_type;`]
|
||||
[[variablelist
|
||||
[[Type]
|
||||
[`T::difference_type` if such a type exists; otherwise
|
||||
`std::ptrdiff_t`.]]]]]
|
||||
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
|
||||
[[variablelist
|
||||
[[Type]
|
||||
[`type` is `T::rebind<U>` if such a type exists; otherwise,
|
||||
`Pointer<V, Args>` if `T` is a class template instantiation of the
|
||||
form `Pointer<T, Args>`, where `Args` is zero or more type
|
||||
arguments; otherwise, the instantiation of `rebind_to` is
|
||||
ill-formed.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member functions]
|
||||
|
||||
[variablelist pointer_traits
|
||||
[[`static pointer pointer_to(`['see below] `v);`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified;
|
||||
otherwise, it is `element_type&`.]]
|
||||
[[Returns]
|
||||
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Requires]
|
||||
[`v` is not a null pointer.]]
|
||||
[[Returns]
|
||||
[A pointer of type `element_type*` that references the same location
|
||||
as the argument.]]]]]]
|
||||
|
||||
[variablelist pointer_traits<T*>
|
||||
[[`static pointer pointer_to(`['see below] `v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified;
|
||||
otherwise, it is `element_type&`.]]
|
||||
[[Returns]
|
||||
[The result of `std::addressof(v)`.]]]]]
|
||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
||||
[[variablelist [[Returns] [The value of `v`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Glen Fernandes implemented `pointer_traits` with reviews and guidance from
|
||||
Peter Dimov.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -42,7 +42,7 @@ addressof(T& o) BOOST_NOEXCEPT
|
||||
|
||||
} /* boost */
|
||||
#else
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
@@ -117,7 +117,6 @@ struct address_of<const volatile addressof_null_t> {
|
||||
} /* detail */
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SFINAE_EXPR) || \
|
||||
defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
|
||||
defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF
|
||||
@@ -171,7 +170,7 @@ const T (*addressof(const T (&o)[N]) BOOST_NOEXCEPT)[N]
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
T&& addressof_declval() BOOST_NOEXCEPT;
|
||||
T addressof_declval() BOOST_NOEXCEPT;
|
||||
|
||||
template<class>
|
||||
struct addressof_void {
|
||||
@@ -262,4 +261,14 @@ addressof(T& o) BOOST_NOEXCEPT
|
||||
} /* boost */
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
const T* addressof(const T&&) = delete;
|
||||
|
||||
} /* boost */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
|
||||
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||
// some other stream, so allow user to configure output stream:
|
||||
@@ -113,6 +114,10 @@ inline const void* test_output_impl(unsigned char* v) { return v; }
|
||||
inline const void* test_output_impl(signed char* v) { return v; }
|
||||
template<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); }
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||
inline const void* test_output_impl(std::nullptr_t v) { return v; }
|
||||
#endif
|
||||
|
||||
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
@@ -147,6 +152,74 @@ template<class T, class U> inline void test_ne_impl( char const * expr1, char co
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_lt_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t < u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " < " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' >= '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_le_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t <= u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " <= " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' > '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_gt_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t > u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " > " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' <= '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_ge_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t >= u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " >= " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' < '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
inline void 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 )
|
||||
{
|
||||
@@ -360,6 +433,11 @@ inline int report_errors()
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_lt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_le_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_gt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_ge_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if !(defined BOOST_NO_EXCEPTIONS)
|
||||
# define BOOST_TRY { try
|
||||
|
||||
244
include/boost/core/pointer_traits.hpp
Normal file
244
include/boost/core/pointer_traits.hpp
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
Copyright 2017 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_POINTER_TRAITS_HPP
|
||||
#define BOOST_CORE_POINTER_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
#include <memory>
|
||||
#else
|
||||
#include <boost/core/addressof.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class U>
|
||||
static typename boost::pointer_traits<U>::element_type*
|
||||
ptr_traits_address(U v) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::pointer_traits<U>::to_address(v);
|
||||
}
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
template<class T>
|
||||
struct pointer_traits
|
||||
: std::pointer_traits<T> {
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef typename std::pointer_traits<T>::template rebind<U> type;
|
||||
};
|
||||
static typename std::pointer_traits<T>::element_type*
|
||||
to_address(T v) BOOST_NOEXCEPT {
|
||||
return detail::ptr_traits_address(v.operator->());
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits<T*>
|
||||
: std::pointer_traits<T*> {
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef U* type;
|
||||
};
|
||||
static T* to_address(T* v) BOOST_NOEXCEPT {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
struct ptr_traits_none { char first, second; };
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_has_element {
|
||||
private:
|
||||
template<class U>
|
||||
static ptr_traits_none call(...);
|
||||
template<class U>
|
||||
static char call(typename U::element_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(call<T>(0)) == 1;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_first;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class T, class U, class... Args>
|
||||
struct ptr_traits_first<T<U, Args...> > {
|
||||
typedef U type;
|
||||
};
|
||||
#else
|
||||
template<template<class> class T, class U>
|
||||
struct ptr_traits_first<T<U> > {
|
||||
typedef U type;
|
||||
};
|
||||
|
||||
template<template<class, class> class T, class U1, class U2>
|
||||
struct ptr_traits_first<T<U1, U2> > {
|
||||
typedef U1 type;
|
||||
};
|
||||
|
||||
template<template<class, class, class> class T, class U1, class U2, class U3>
|
||||
struct ptr_traits_first<T<U1, U2, U3> > {
|
||||
typedef U1 type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T, bool = ptr_traits_has_element<T>::value>
|
||||
struct ptr_traits_element {
|
||||
typedef typename T::element_type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_element<T, false> {
|
||||
typedef typename ptr_traits_first<T>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_has_difference {
|
||||
private:
|
||||
template<class U>
|
||||
static ptr_traits_none call(...);
|
||||
template<class U>
|
||||
static char call(typename U::difference_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(call<T>(0)) == 1;
|
||||
};
|
||||
|
||||
template<class T, bool = ptr_traits_has_difference<T>::value>
|
||||
struct ptr_traits_difference {
|
||||
typedef typename T::difference_type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_difference<T, false> {
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template<class T, class V>
|
||||
struct ptr_traits_has_rebind {
|
||||
private:
|
||||
template<class U>
|
||||
static ptr_traits_none call(...);
|
||||
template<class U>
|
||||
static char call(typename U::template rebind<V>* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(call<T>(0)) == 1;
|
||||
};
|
||||
|
||||
template<class T, class V>
|
||||
struct ptr_traits_rebind_to;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class T, class U, class... Args, class V>
|
||||
struct ptr_traits_rebind_to<T<U, Args...>, V> {
|
||||
typedef T<V, Args...> type;
|
||||
};
|
||||
#else
|
||||
template<template<class> class T, class U, class V>
|
||||
struct ptr_traits_rebind_to<T<U>, V> {
|
||||
typedef T<V> type;
|
||||
};
|
||||
|
||||
template<template<class, class> class T, class U1, class U2, class V>
|
||||
struct ptr_traits_rebind_to<T<U1, U2>, V> {
|
||||
typedef T<V, U2> type;
|
||||
};
|
||||
|
||||
template<template<class, class, class> class T,
|
||||
class U1, class U2, class U3, class V>
|
||||
struct ptr_traits_rebind_to<T<U1, U2, U3>, V> {
|
||||
typedef T<V, U2, U3> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T, class U, bool = ptr_traits_has_rebind<T, U>::value>
|
||||
struct ptr_traits_rebind {
|
||||
typedef typename T::template rebind<U> type;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct ptr_traits_rebind<T, U, false> {
|
||||
typedef typename ptr_traits_rebind_to<T, U>::type type;
|
||||
};
|
||||
#else
|
||||
template<class T, class U>
|
||||
struct ptr_traits_rebind {
|
||||
typedef typename ptr_traits_rebind_to<T, U>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_value {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ptr_traits_value<void> {
|
||||
typedef struct { } type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits {
|
||||
typedef T pointer;
|
||||
typedef typename detail::ptr_traits_element<T>::type element_type;
|
||||
typedef typename detail::ptr_traits_difference<T>::type difference_type;
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef typename detail::ptr_traits_rebind<T, U>::type type;
|
||||
};
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class U>
|
||||
using rebind = typename detail::ptr_traits_rebind<T, U>::type;
|
||||
#endif
|
||||
static pointer
|
||||
pointer_to(typename detail::ptr_traits_value<element_type>::type& v) {
|
||||
return pointer::pointer_to(v);
|
||||
}
|
||||
static element_type* to_address(pointer v) BOOST_NOEXCEPT {
|
||||
return detail::ptr_traits_address(v.operator->());
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits<T*> {
|
||||
typedef T* pointer;
|
||||
typedef T element_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef U* type;
|
||||
};
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class U>
|
||||
using rebind = U*;
|
||||
#endif
|
||||
static T*
|
||||
pointer_to(typename detail::ptr_traits_value<T>::type& v) BOOST_NOEXCEPT {
|
||||
return addressof(v);
|
||||
}
|
||||
static T* to_address(T* v) BOOST_NOEXCEPT {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -8,8 +8,8 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
//
|
||||
// ref.hpp - ref/cref, useful helper functions
|
||||
|
||||
@@ -14,6 +14,7 @@ run addressof_test2.cpp ;
|
||||
run addressof_np_test.cpp ;
|
||||
run addressof_fn_test.cpp ;
|
||||
compile addressof_constexpr_test.cpp ;
|
||||
compile-fail addressof_fail_rvalue.cpp ;
|
||||
|
||||
run checked_delete_test.cpp ;
|
||||
compile-fail checked_delete_fail.cpp ;
|
||||
@@ -68,6 +69,10 @@ run lightweight_test_test2.cpp ;
|
||||
run lightweight_test_all_eq_test.cpp ;
|
||||
run lightweight_test_all_with_test.cpp ;
|
||||
run lightweight_test_all_with_fail.cpp ;
|
||||
run lightweight_test_lt_le_test.cpp ;
|
||||
run lightweight_test_gt_ge_test.cpp ;
|
||||
|
||||
run lightweight_test_eq_nullptr.cpp ;
|
||||
|
||||
run-fail lightweight_test_fail.cpp ;
|
||||
run-fail lightweight_test_fail2.cpp ;
|
||||
@@ -81,6 +86,10 @@ 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_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 is_same_test.cpp ;
|
||||
|
||||
@@ -101,5 +110,12 @@ compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
|
||||
|
||||
run underlying_type.cpp ;
|
||||
|
||||
run pointer_traits_to_address_test.cpp ;
|
||||
run pointer_traits_pointer_test.cpp ;
|
||||
run pointer_traits_element_type_test.cpp ;
|
||||
run pointer_traits_difference_type_test.cpp ;
|
||||
run pointer_traits_rebind_test.cpp ;
|
||||
run pointer_traits_pointer_to_test.cpp ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
26
test/addressof_fail_rvalue.cpp
Normal file
26
test/addressof_fail_rvalue.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2017 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/addressof.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
struct type { };
|
||||
|
||||
inline const type function()
|
||||
{
|
||||
return type();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
(void)boost::addressof(function());
|
||||
}
|
||||
#else
|
||||
#error Requires rvalue references and deleted functions
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// get_pointer_test.cpp
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
// Copyright 2014, 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -27,11 +27,23 @@ int main()
|
||||
delete p;
|
||||
}
|
||||
|
||||
{
|
||||
X * p = 0;
|
||||
BOOST_TEST( get_pointer( p ) == 0 );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_AUTO_PTR )
|
||||
|
||||
{
|
||||
std::auto_ptr< X > p( new X );
|
||||
BOOST_TEST( get_pointer( p ) == p.get() );
|
||||
}
|
||||
|
||||
{
|
||||
std::auto_ptr< X > p;
|
||||
BOOST_TEST( get_pointer( p ) == 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_SMART_PTR )
|
||||
@@ -41,11 +53,21 @@ int main()
|
||||
BOOST_TEST( get_pointer( p ) == p.get() );
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr< X > p;
|
||||
BOOST_TEST( get_pointer( p ) == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
std::shared_ptr< X > p( new X );
|
||||
BOOST_TEST( get_pointer( p ) == p.get() );
|
||||
}
|
||||
|
||||
{
|
||||
std::shared_ptr< X > p;
|
||||
BOOST_TEST( get_pointer( p ) == 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
28
test/lightweight_test_eq_nullptr.cpp
Normal file
28
test/lightweight_test_eq_nullptr.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Test BOOST_TEST_EQ( p, nullptr )
|
||||
//
|
||||
// Copyright 2017 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/config.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||
|
||||
int x = 0;
|
||||
int* p1 = 0;
|
||||
int* p2 = &x;
|
||||
|
||||
BOOST_TEST_EQ( p1, nullptr );
|
||||
BOOST_TEST_NE( p2, nullptr );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
20
test/lightweight_test_ge_fail.cpp
Normal file
20
test/lightweight_test_ge_fail.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Negative test for BOOST_TEST_GE
|
||||
//
|
||||
// Copyright 2017 Kohei Takahashi
|
||||
//
|
||||
// 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()
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
BOOST_TEST_GE( x, 1 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
20
test/lightweight_test_gt_fail.cpp
Normal file
20
test/lightweight_test_gt_fail.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Negative test for BOOST_TEST_GT
|
||||
//
|
||||
// Copyright 2017 Kohei Takahashi
|
||||
//
|
||||
// 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()
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
BOOST_TEST_GT( x, 0 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/lightweight_test_gt_ge_test.cpp
Normal file
34
test/lightweight_test_gt_ge_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Test for BOOST_TEST_GT, BOOST_TEST_GE
|
||||
//
|
||||
// Copyright 2017 Kohei Takahashi
|
||||
//
|
||||
// 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()
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
BOOST_TEST_GT( x, -1 );
|
||||
BOOST_TEST_GT( ++x, 0 );
|
||||
BOOST_TEST_GT( x++, 0 );
|
||||
|
||||
BOOST_TEST_GE( x, 2 );
|
||||
BOOST_TEST_GE( ++x, 3 );
|
||||
BOOST_TEST_GE( x++, 3 );
|
||||
|
||||
int y = 5;
|
||||
|
||||
BOOST_TEST_GT( ++y, ++x );
|
||||
BOOST_TEST_GT( y++, x++ );
|
||||
|
||||
BOOST_TEST_GE( ++y, x );
|
||||
BOOST_TEST_GE( y++, x++ );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
20
test/lightweight_test_le_fail.cpp
Normal file
20
test/lightweight_test_le_fail.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Negative test for BOOST_TEST_LE
|
||||
//
|
||||
// Copyright 2017 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()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_TEST_LE( x, 0 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
20
test/lightweight_test_lt_fail.cpp
Normal file
20
test/lightweight_test_lt_fail.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Negative test for BOOST_TEST_LT
|
||||
//
|
||||
// Copyright 2014, 2017 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()
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
BOOST_TEST_LT( x, 0 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/lightweight_test_lt_le_test.cpp
Normal file
34
test/lightweight_test_lt_le_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Test for BOOST_TEST_LT, BOOST_TEST_LE
|
||||
//
|
||||
// Copyright 2014, 2017 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()
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
BOOST_TEST_LT( x, 1 );
|
||||
BOOST_TEST_LT( ++x, 2 );
|
||||
BOOST_TEST_LT( x++, 3 );
|
||||
|
||||
BOOST_TEST_LE( x, 2 );
|
||||
BOOST_TEST_LE( ++x, 3 );
|
||||
BOOST_TEST_LE( x++, 4 );
|
||||
|
||||
int y = 3;
|
||||
|
||||
BOOST_TEST_LT( ++y, ++x );
|
||||
BOOST_TEST_LT( y++, x++ );
|
||||
|
||||
BOOST_TEST_LE( ++y, x );
|
||||
BOOST_TEST_LE( y++, x++ );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
41
test/pointer_traits_difference_type_test.cpp
Normal file
41
test/pointer_traits_difference_type_test.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2017 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/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P { };
|
||||
|
||||
template<class T>
|
||||
struct E {
|
||||
typedef long difference_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<int*>::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<P<int> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
|
||||
boost::pointer_traits<E<int> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<void*>::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<P<void> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
|
||||
boost::pointer_traits<E<void> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<const int*>::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<P<const int> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
|
||||
boost::pointer_traits<E<const int> >::difference_type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
83
test/pointer_traits_element_type_test.cpp
Normal file
83
test/pointer_traits_element_type_test.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright 2017 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/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P1 { };
|
||||
|
||||
template<class T1, class T2>
|
||||
struct P2 { };
|
||||
|
||||
template<class T1, class T2, class T3>
|
||||
struct P3 { };
|
||||
|
||||
template<class T>
|
||||
struct E1 {
|
||||
typedef bool element_type;
|
||||
};
|
||||
|
||||
template<class T1, class T2>
|
||||
struct E2 {
|
||||
typedef bool element_type;
|
||||
};
|
||||
|
||||
template<class T1, class T2, class T3>
|
||||
struct E3 {
|
||||
typedef bool element_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class T, class... U>
|
||||
struct P { };
|
||||
|
||||
template<class T, class... U>
|
||||
struct E {
|
||||
typedef bool element_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::pointer_traits<int*>::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::pointer_traits<P1<int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::pointer_traits<P2<int, char> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::pointer_traits<P3<int, char, char> >::element_type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::pointer_traits<P<int, char, char, char> >::element_type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
boost::pointer_traits<E1<int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
boost::pointer_traits<E2<int, int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
boost::pointer_traits<E3<int, int, int> >::element_type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
boost::pointer_traits<E<int, int, int, int> >::element_type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
|
||||
boost::pointer_traits<void*>::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
|
||||
boost::pointer_traits<P1<void> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
boost::pointer_traits<E1<void> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
|
||||
boost::pointer_traits<const int*>::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
|
||||
boost::pointer_traits<P1<const int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
boost::pointer_traits<E1<const int> >::element_type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
30
test/pointer_traits_pointer_test.cpp
Normal file
30
test/pointer_traits_pointer_test.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2017 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/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P { };
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::pointer_traits<int*>::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<int>,
|
||||
boost::pointer_traits<P<int> >::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
boost::pointer_traits<void*>::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<void>,
|
||||
boost::pointer_traits<P<void> >::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
boost::pointer_traits<const int*>::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<const int>,
|
||||
boost::pointer_traits<P<const int> >::pointer>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
63
test/pointer_traits_pointer_to_test.cpp
Normal file
63
test/pointer_traits_pointer_to_test.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2017 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/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class pointer {
|
||||
public:
|
||||
typedef typename boost::pointer_traits<T>::element_type element_type;
|
||||
pointer(T value)
|
||||
: value_(value) { }
|
||||
T get() const BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
static pointer<T> pointer_to(element_type& value) {
|
||||
return pointer<T>(&value);
|
||||
}
|
||||
private:
|
||||
T value_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline bool
|
||||
operator==(const pointer<T>& lhs, const pointer<T>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs.get() == rhs.get();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
typedef int* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
|
||||
}
|
||||
{
|
||||
typedef pointer<int*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
|
||||
}
|
||||
{
|
||||
typedef pointer<pointer<int*> > type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
|
||||
}
|
||||
{
|
||||
typedef const int* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
|
||||
}
|
||||
{
|
||||
typedef pointer<const int*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
107
test/pointer_traits_rebind_test.cpp
Normal file
107
test/pointer_traits_rebind_test.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
Copyright 2017 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/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P1 { };
|
||||
|
||||
template<class T1, class T2>
|
||||
struct P2 { };
|
||||
|
||||
template<class T1, class T2, class T3>
|
||||
struct P3 { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T>
|
||||
struct E1 {
|
||||
template<class U>
|
||||
using rebind = E1<bool>;
|
||||
};
|
||||
|
||||
template<class T1, class T2>
|
||||
struct E2 {
|
||||
template<class U>
|
||||
using rebind = E2<bool, T2>;
|
||||
};
|
||||
|
||||
template<class T1, class T2, class T3>
|
||||
struct E3 {
|
||||
template<class U>
|
||||
using rebind = E3<bool, T2, T3>;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class T, class... U>
|
||||
struct P { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T, class... U>
|
||||
struct E {
|
||||
template<class V>
|
||||
using rebind = E<bool, U...>;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct R { };
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
|
||||
boost::pointer_traits<R*>::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<char>,
|
||||
boost::pointer_traits<P1<R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P2<char, R>,
|
||||
boost::pointer_traits<P2<R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P3<char, R, R>,
|
||||
boost::pointer_traits<P3<R, R, R> >::rebind_to<char>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<char, R, R, R>,
|
||||
boost::pointer_traits<P<R, R, R, R> >::rebind_to<char>::type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
boost::pointer_traits<R*>::rebind_to<void>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<void>,
|
||||
boost::pointer_traits<P1<R> >::rebind_to<void>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<R*,
|
||||
boost::pointer_traits<void*>::rebind_to<R>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<R>,
|
||||
boost::pointer_traits<P1<void> >::rebind_to<R>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
boost::pointer_traits<R*>::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<const int>,
|
||||
boost::pointer_traits<P1<R> >::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::pointer_traits<const R*>::rebind_to<int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
|
||||
boost::pointer_traits<P1<const R> >::rebind_to<int>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
|
||||
boost::pointer_traits<E2<R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
|
||||
boost::pointer_traits<E3<R, R, R> >::rebind_to<char>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
|
||||
boost::pointer_traits<E<R, R, R, R> >::rebind_to<char>::type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<void>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<void> >::rebind_to<R>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<const R> >::rebind_to<int>::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
63
test/pointer_traits_to_address_test.cpp
Normal file
63
test/pointer_traits_to_address_test.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2017 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/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class pointer {
|
||||
public:
|
||||
typedef typename boost::pointer_traits<T>::element_type element_type;
|
||||
pointer(T value)
|
||||
: value_(value) { }
|
||||
T operator->() const BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
private:
|
||||
T value_;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
typedef int* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<int*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<pointer<int*> > type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef void* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<void*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef const int* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<const int*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user