From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/callable_traits/CMakeLists.txt | 135 ++++++++ src/boost/libs/callable_traits/LICENSE.md | 25 ++ src/boost/libs/callable_traits/README.md | 19 + .../libs/callable_traits/example/CMakeLists.txt | 25 ++ src/boost/libs/callable_traits/example/Jamfile.v2 | 19 + .../callable_traits/example/add_member_const.cpp | 49 +++ .../libs/callable_traits/example/add_member_cv.cpp | 49 +++ .../example/add_member_lvalue_reference.cpp | 53 +++ .../example/add_member_rvalue_reference.cpp | 53 +++ .../example/add_member_volatile.cpp | 50 +++ .../libs/callable_traits/example/add_noexcept.cpp | 29 ++ .../example/add_transaction_safe.cpp | 30 ++ .../libs/callable_traits/example/add_varargs.cpp | 44 +++ .../example/apply_member_pointer.cpp | 94 +++++ src/boost/libs/callable_traits/example/args.cpp | 69 ++++ .../libs/callable_traits/example/class_of.cpp | 22 ++ .../libs/callable_traits/example/function_type.cpp | 48 +++ .../function_types_remove_const_comparison.cpp | 21 ++ .../example/has_member_qualifiers.cpp | 21 ++ .../libs/callable_traits/example/has_varargs.cpp | 24 ++ .../callable_traits/example/has_void_return.cpp | 18 + src/boost/libs/callable_traits/example/intro.cpp | 62 ++++ .../callable_traits/example/is_const_member.cpp | 20 ++ .../libs/callable_traits/example/is_cv_member.cpp | 22 ++ .../libs/callable_traits/example/is_invocable.cpp | 24 ++ .../example/is_lvalue_reference_member.cpp | 32 ++ .../libs/callable_traits/example/is_noexcept.cpp | 33 ++ .../example/is_reference_member.cpp | 32 ++ .../example/is_rvalue_reference_member.cpp | 32 ++ .../example/is_transaction_safe.cpp | 33 ++ .../callable_traits/example/is_volatile_member.cpp | 32 ++ .../libs/callable_traits/example/overview.cpp | 78 +++++ .../callable_traits/example/qualified_class_of.cpp | 32 ++ .../example/remove_member_const.cpp | 45 +++ .../callable_traits/example/remove_member_cv.cpp | 45 +++ .../example/remove_member_reference.cpp | 45 +++ .../example/remove_member_volatile.cpp | 45 +++ .../callable_traits/example/remove_noexcept.cpp | 29 ++ .../example/remove_transaction_safe.cpp | 29 ++ .../callable_traits/example/remove_varargs.cpp | 41 +++ .../libs/callable_traits/example/return_type.cpp | 42 +++ src/boost/libs/callable_traits/example/void.cpp | 31 ++ src/boost/libs/callable_traits/index.html | 18 + src/boost/libs/callable_traits/meta/libraries.json | 10 + .../libs/callable_traits/scripts/wandbox_deploy.py | 119 +++++++ src/boost/libs/callable_traits/test/CMakeLists.txt | 41 +++ src/boost/libs/callable_traits/test/Jamfile.v2 | 22 ++ .../libs/callable_traits/test/add_member_const.cpp | 103 ++++++ .../libs/callable_traits/test/add_member_cv.cpp | 104 ++++++ .../test/add_member_lvalue_reference.cpp | 206 +++++++++++ .../test/add_member_rvalue_reference.cpp | 167 +++++++++ .../callable_traits/test/add_member_volatile.cpp | 76 ++++ .../libs/callable_traits/test/add_noexcept.cpp | 45 +++ .../test/add_noexcept_constraints.cpp | 51 +++ .../callable_traits/test/add_transaction_safe.cpp | 45 +++ .../test/add_transaction_safe_constraints.cpp | 51 +++ .../libs/callable_traits/test/add_varargs.cpp | 188 ++++++++++ .../test/add_varargs_constraints.cpp | 45 +++ .../test/apply_member_pointer_constraints.cpp | 32 ++ .../test/apply_member_pointer_function.cpp | 114 ++++++ .../test/apply_member_pointer_pmd.cpp | 31 ++ .../test/apply_member_pointer_pmf.cpp | 95 +++++ src/boost/libs/callable_traits/test/args.cpp | 67 ++++ .../libs/callable_traits/test/args_constraints.cpp | 46 +++ src/boost/libs/callable_traits/test/class_of.cpp | 52 +++ .../callable_traits/test/class_of_constraints.cpp | 45 +++ .../libs/callable_traits/test/collapse_flags.cpp | 38 ++ .../libs/callable_traits/test/function_type.cpp | 96 ++++++ .../test/function_type_constraints.cpp | 46 +++ .../callable_traits/test/has_member_qualifiers.cpp | 128 +++++++ .../test/has_member_qualifiers_simple.cpp | 58 ++++ .../libs/callable_traits/test/has_varargs.cpp | 214 ++++++++++++ .../libs/callable_traits/test/has_void_return.cpp | 58 ++++ .../libs/callable_traits/test/is_const_member.cpp | 121 +++++++ .../libs/callable_traits/test/is_cv_member.cpp | 121 +++++++ .../libs/callable_traits/test/is_invocable.cpp | 381 +++++++++++++++++++++ .../libs/callable_traits/test/is_invocable_r.cpp | 328 ++++++++++++++++++ .../test/is_lvalue_reference_member.cpp | 126 +++++++ .../libs/callable_traits/test/is_noexcept.cpp | 43 +++ .../test/is_rvalue_reference_member.cpp | 126 +++++++ .../callable_traits/test/is_transaction_safe.cpp | 41 +++ .../callable_traits/test/is_volatile_member.cpp | 121 +++++++ .../callable_traits/test/qualified_class_of.cpp | 52 +++ .../test/qualified_class_of_constraints.cpp | 52 +++ .../test/qualifier_metafunction_constraints.cpp | 48 +++ .../test/qualifier_metafunction_constraints.hpp | 48 +++ .../callable_traits/test/remove_member_const.cpp | 106 ++++++ .../test/remove_member_reference.cpp | 78 +++++ .../test/remove_member_volatile.cpp | 77 +++++ .../libs/callable_traits/test/remove_noexcept.cpp | 36 ++ .../test/remove_noexcept_constraints.cpp | 51 +++ .../test/remove_transaction_safe.cpp | 39 +++ .../test/remove_transaction_safe_constraints.cpp | 51 +++ .../libs/callable_traits/test/remove_varargs.cpp | 190 ++++++++++ .../test/remove_varargs_constraints.hpp | 45 +++ .../libs/callable_traits/test/return_type.cpp | 56 +++ src/boost/libs/callable_traits/test/test.hpp | 56 +++ 97 files changed, 6485 insertions(+) create mode 100644 src/boost/libs/callable_traits/CMakeLists.txt create mode 100644 src/boost/libs/callable_traits/LICENSE.md create mode 100644 src/boost/libs/callable_traits/README.md create mode 100644 src/boost/libs/callable_traits/example/CMakeLists.txt create mode 100644 src/boost/libs/callable_traits/example/Jamfile.v2 create mode 100644 src/boost/libs/callable_traits/example/add_member_const.cpp create mode 100644 src/boost/libs/callable_traits/example/add_member_cv.cpp create mode 100644 src/boost/libs/callable_traits/example/add_member_lvalue_reference.cpp create mode 100644 src/boost/libs/callable_traits/example/add_member_rvalue_reference.cpp create mode 100644 src/boost/libs/callable_traits/example/add_member_volatile.cpp create mode 100644 src/boost/libs/callable_traits/example/add_noexcept.cpp create mode 100644 src/boost/libs/callable_traits/example/add_transaction_safe.cpp create mode 100644 src/boost/libs/callable_traits/example/add_varargs.cpp create mode 100644 src/boost/libs/callable_traits/example/apply_member_pointer.cpp create mode 100644 src/boost/libs/callable_traits/example/args.cpp create mode 100644 src/boost/libs/callable_traits/example/class_of.cpp create mode 100644 src/boost/libs/callable_traits/example/function_type.cpp create mode 100644 src/boost/libs/callable_traits/example/function_types_remove_const_comparison.cpp create mode 100644 src/boost/libs/callable_traits/example/has_member_qualifiers.cpp create mode 100644 src/boost/libs/callable_traits/example/has_varargs.cpp create mode 100644 src/boost/libs/callable_traits/example/has_void_return.cpp create mode 100644 src/boost/libs/callable_traits/example/intro.cpp create mode 100644 src/boost/libs/callable_traits/example/is_const_member.cpp create mode 100644 src/boost/libs/callable_traits/example/is_cv_member.cpp create mode 100644 src/boost/libs/callable_traits/example/is_invocable.cpp create mode 100644 src/boost/libs/callable_traits/example/is_lvalue_reference_member.cpp create mode 100644 src/boost/libs/callable_traits/example/is_noexcept.cpp create mode 100644 src/boost/libs/callable_traits/example/is_reference_member.cpp create mode 100644 src/boost/libs/callable_traits/example/is_rvalue_reference_member.cpp create mode 100644 src/boost/libs/callable_traits/example/is_transaction_safe.cpp create mode 100644 src/boost/libs/callable_traits/example/is_volatile_member.cpp create mode 100644 src/boost/libs/callable_traits/example/overview.cpp create mode 100644 src/boost/libs/callable_traits/example/qualified_class_of.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_member_const.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_member_cv.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_member_reference.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_member_volatile.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_noexcept.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_transaction_safe.cpp create mode 100644 src/boost/libs/callable_traits/example/remove_varargs.cpp create mode 100644 src/boost/libs/callable_traits/example/return_type.cpp create mode 100644 src/boost/libs/callable_traits/example/void.cpp create mode 100644 src/boost/libs/callable_traits/index.html create mode 100644 src/boost/libs/callable_traits/meta/libraries.json create mode 100755 src/boost/libs/callable_traits/scripts/wandbox_deploy.py create mode 100644 src/boost/libs/callable_traits/test/CMakeLists.txt create mode 100644 src/boost/libs/callable_traits/test/Jamfile.v2 create mode 100644 src/boost/libs/callable_traits/test/add_member_const.cpp create mode 100644 src/boost/libs/callable_traits/test/add_member_cv.cpp create mode 100644 src/boost/libs/callable_traits/test/add_member_lvalue_reference.cpp create mode 100644 src/boost/libs/callable_traits/test/add_member_rvalue_reference.cpp create mode 100644 src/boost/libs/callable_traits/test/add_member_volatile.cpp create mode 100644 src/boost/libs/callable_traits/test/add_noexcept.cpp create mode 100644 src/boost/libs/callable_traits/test/add_noexcept_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/add_transaction_safe.cpp create mode 100644 src/boost/libs/callable_traits/test/add_transaction_safe_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/add_varargs.cpp create mode 100644 src/boost/libs/callable_traits/test/add_varargs_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/apply_member_pointer_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/apply_member_pointer_function.cpp create mode 100644 src/boost/libs/callable_traits/test/apply_member_pointer_pmd.cpp create mode 100644 src/boost/libs/callable_traits/test/apply_member_pointer_pmf.cpp create mode 100644 src/boost/libs/callable_traits/test/args.cpp create mode 100644 src/boost/libs/callable_traits/test/args_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/class_of.cpp create mode 100644 src/boost/libs/callable_traits/test/class_of_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/collapse_flags.cpp create mode 100644 src/boost/libs/callable_traits/test/function_type.cpp create mode 100644 src/boost/libs/callable_traits/test/function_type_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/has_member_qualifiers.cpp create mode 100644 src/boost/libs/callable_traits/test/has_member_qualifiers_simple.cpp create mode 100644 src/boost/libs/callable_traits/test/has_varargs.cpp create mode 100644 src/boost/libs/callable_traits/test/has_void_return.cpp create mode 100644 src/boost/libs/callable_traits/test/is_const_member.cpp create mode 100644 src/boost/libs/callable_traits/test/is_cv_member.cpp create mode 100644 src/boost/libs/callable_traits/test/is_invocable.cpp create mode 100644 src/boost/libs/callable_traits/test/is_invocable_r.cpp create mode 100644 src/boost/libs/callable_traits/test/is_lvalue_reference_member.cpp create mode 100644 src/boost/libs/callable_traits/test/is_noexcept.cpp create mode 100644 src/boost/libs/callable_traits/test/is_rvalue_reference_member.cpp create mode 100644 src/boost/libs/callable_traits/test/is_transaction_safe.cpp create mode 100644 src/boost/libs/callable_traits/test/is_volatile_member.cpp create mode 100644 src/boost/libs/callable_traits/test/qualified_class_of.cpp create mode 100644 src/boost/libs/callable_traits/test/qualified_class_of_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.hpp create mode 100644 src/boost/libs/callable_traits/test/remove_member_const.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_member_reference.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_member_volatile.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_noexcept.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_noexcept_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_transaction_safe.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_transaction_safe_constraints.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_varargs.cpp create mode 100644 src/boost/libs/callable_traits/test/remove_varargs_constraints.hpp create mode 100644 src/boost/libs/callable_traits/test/return_type.cpp create mode 100644 src/boost/libs/callable_traits/test/test.hpp (limited to 'src/boost/libs/callable_traits') diff --git a/src/boost/libs/callable_traits/CMakeLists.txt b/src/boost/libs/callable_traits/CMakeLists.txt new file mode 100644 index 000000000..c45552eb8 --- /dev/null +++ b/src/boost/libs/callable_traits/CMakeLists.txt @@ -0,0 +1,135 @@ + +# Copyright Louis Dionne 2015 +# Modified Work Copyright Barrett Adair 2015-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +cmake_minimum_required(VERSION 3.0) +project(boost_callable_traits CXX) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +enable_testing() + +set (CMAKE_CXX_STANDARD ${boost_callable_traits_CXX_STD}) + +# Setting up CMake options and compiler flags (more flags can be set on a per-target basis or in subdirectories) + +include(CheckCXXCompilerFlag) +macro(boost_callable_traits_append_flag testname flag) + check_cxx_compiler_flag(${flag} ${testname}) + if (${testname}) + add_compile_options(${flag}) + endif() +endmacro() + +if(NOT MSVC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + + # enable all warnings and treat them all as errors + boost_callable_traits_append_flag(boost_callable_traits_HAS_WERROR -Werror) + boost_callable_traits_append_flag(boost_callable_traits_HAS_WX -WX) + boost_callable_traits_append_flag(boost_callable_traits_HAS_W -W) + boost_callable_traits_append_flag(boost_callable_traits_HAS_WALL -Wall) + boost_callable_traits_append_flag(boost_callable_traits_HAS_WEXTRA -Wextra) +endif() + +if(MSVC) + + # MSVC/Clang-cl builds need -Qunused-arguments + boost_callable_traits_append_flag(boost_callable_traits_HAS_QUNUSED_ARGUMENTS -Qunused-arguments) +else() + + # for better template error debugging + boost_callable_traits_append_flag(boost_callable_traits_HAS_FTEMPLATE_BACKTRACE_LIMIT -ftemplate-backtrace-limit=0) + + # enforce strict standards compliance + boost_callable_traits_append_flag(boost_callable_traits_HAS_PEDANTIC -pedantic) + + # use the most recent C++ standard available + boost_callable_traits_append_flag(boost_callable_traits_HAS_STDCXX0x -std=c++0x) + boost_callable_traits_append_flag(boost_callable_traits_HAS_STDCXX1y -std=c++1y) + boost_callable_traits_append_flag(boost_callable_traits_HAS_STDCXX1z -std=c++1z) + boost_callable_traits_append_flag(boost_callable_traits_HAS_STDCXX17 -std=c++17) + boost_callable_traits_append_flag(boost_callable_traits_HAS_STDCXX2a -std=c++2a) +endif() + +# transactional memory - currently only available in GCC 6 and later +if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + boost_callable_traits_append_flag(boost_callable_traits_HAS_FGNU_TM -fgnu-tm) +endif() + +add_library(boost_callable_traits INTERFACE) +set_property(TARGET boost_callable_traits PROPERTY EXPORT_NAME callable_traits) +add_library(Boost::callable_traits ALIAS boost_callable_traits) + +target_include_directories(boost_callable_traits INTERFACE + "$" + $) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + +# +#find_package(Doxygen) +##find_package(Meta) +#find_package(PythonInterp 2.7) +#find_package(Ruby 2.1) + +############################################################################## +# boost_callable_traits_target_name_for( [ext]) +# Returns the target name associated to a source file. If the path of the +# source file relative from the root of boost_callable_traits is `path/to/source/file.ext`, +# the target name associated to it will be `path.to.source.file`. +# +# The extension of the file should be specified as a last argument. If no +# extension is specified, the `.cpp` extension is assumed. +############################################################################## + +function(boost_callable_traits_target_name_for out file) + if (NOT ARGV2) + set(_extension ".cpp") + else() + set(_extension "${ARGV2}") + endif() + + file(RELATIVE_PATH _relative ${boost_callable_traits_SOURCE_DIR} ${file}) + string(REPLACE "${_extension}" "" _name ${_relative}) + string(REGEX REPLACE "/" "." _name ${_name}) + set(${out} "${_name}" PARENT_SCOPE) +endfunction() + +############################################################################## +# boost_callable_traits_add_test( [...]) +# Creates a test called `name`, which runs the given `command` with the given args. +############################################################################## + +function(boost_callable_traits_add_test name) + if (boost_callable_traits_ENABLE_MEMCHECK) + add_test(${name} ${Valgrind_EXECUTABLE} --leak-check=full --error-exitcode=1 ${ARGN}) + else() + add_test(${name} ${ARGN}) + endif() +endfunction() + +############################################################################## +# Setup the `check` target to build and then run all the tests and examples. +############################################################################## + +add_custom_target(callable_traits_check + COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Build and then run all the tests and examples.") +if (NOT TARGET check) + add_custom_target(check DEPENDS callable_traits_check) +else() + add_dependencies(check callable_traits_check) +endif() + +add_subdirectory(example) +add_subdirectory(test) + +############################################################################## +# Setup the 'install' target and the package config file. +############################################################################## +install(TARGETS boost_callable_traits EXPORT CallableTraitsConfig) +install(EXPORT CallableTraitsConfig DESTINATION lib/cmake/CallableTraits) +install(DIRECTORY include/boost DESTINATION include FILES_MATCHING PATTERN "*.hpp") + +endif() diff --git a/src/boost/libs/callable_traits/LICENSE.md b/src/boost/libs/callable_traits/LICENSE.md new file mode 100644 index 000000000..901f174c9 --- /dev/null +++ b/src/boost/libs/callable_traits/LICENSE.md @@ -0,0 +1,25 @@ +Copyright 2015-2016 Barrett Adair + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/boost/libs/callable_traits/README.md b/src/boost/libs/callable_traits/README.md new file mode 100644 index 000000000..935520d2f --- /dev/null +++ b/src/boost/libs/callable_traits/README.md @@ -0,0 +1,19 @@ + + +# Boost.CallableTraits ![Travis status][badge.Travis] ![Appveyor status][badge.Appveyor] + +CallableTraits is a C++11 header-only library for the inspection, synthesis, and decomposition of callable types. + +The latest documentation is available [here](http://www.boost.org/doc/libs/develop/libs/callable_traits/doc/html/index.html). + +CallableTraits was [formally reviewed](http://www.boost.org/community/reviews.html) and [accepted](https://lists.boost.org/Archives/boost/2017/04/234513.php) into the [Boost C++ Libraries](http://www.boost.org/). CallableTraits is available in Boost 1.66 (December 2017) and later. You can also download CallableTraits as a standalone library [here](https://github.com/boostorg/callable_traits/releases/latest). + +Licensed under the [Boost Software License, Version 1.0](LICENSE.md). + + +[badge.Appveyor]: https://ci.appveyor.com/api/projects/status/uf0l91v7l4wc4kw6/branch/master?svg=true +[badge.Travis]: https://travis-ci.org/boostorg/callable_traits.svg?branch=master diff --git a/src/boost/libs/callable_traits/example/CMakeLists.txt b/src/boost/libs/callable_traits/example/CMakeLists.txt new file mode 100644 index 000000000..5a6108d28 --- /dev/null +++ b/src/boost/libs/callable_traits/example/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright Louis Dionne 2015 +# Modified Work Copyright Barrett Adair 2015-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +add_custom_target(examples COMMENT "Build all the examples.") +add_dependencies(callable_traits_check examples) + +include_directories(${boost_callable_traits_SOURCE_DIR}/include) + +file(GLOB_RECURSE EXAMPLES "*.cpp") +file(GLOB_RECURSE EXPERIMENTAL_EXAMPLES "experimental*.cpp") + +if (NOT BOOST_CLBL_TRTS_BUILD_EXPERIMENTAL) + foreach(_experimental IN LISTS EXPERIMENTAL_EXAMPLES) + list(REMOVE_ITEM EXAMPLES ${_experimental}) + endforeach() +endif() + +foreach(_file IN LISTS EXAMPLES) + boost_callable_traits_target_name_for(_target "${_file}") + add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") + boost_callable_traits_add_test(${_target} ${CMAKE_CURRENT_BINARY_DIR}/${_target}) + add_dependencies(examples ${_target}) +endforeach() diff --git a/src/boost/libs/callable_traits/example/Jamfile.v2 b/src/boost/libs/callable_traits/example/Jamfile.v2 new file mode 100644 index 000000000..d94b84f65 --- /dev/null +++ b/src/boost/libs/callable_traits/example/Jamfile.v2 @@ -0,0 +1,19 @@ +# Copyright Louis Dionne 2013-2016 +# Modified Work Copyright Barrett Adair 2016-2017 +# Copyright 2017 Peter Dimov +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +import testing ; + +project : + requirements + clang:"-pedantic -Wall -Wextra" + darwin:"-pedantic -Wall -Wextra" +; + +for local source in [ glob *.cpp ] +{ + run $(source) ; +} diff --git a/src/boost/libs/callable_traits/example/add_member_const.cpp b/src/boost/libs/callable_traits/example/add_member_const.cpp new file mode 100644 index 000000000..83dba2a96 --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_member_const.cpp @@ -0,0 +1,49 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_const +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = int(foo::*)(); + using expect = int(foo::*)() const; + using test = ct::add_member_const_t; + static_assert(std::is_same::value, ""); + } { + // add_member_const_t doesn't change anything when + // the function type is already const. + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() const &&; + using test = ct::add_member_const_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() volatile &; + using expect = int(foo::*)() const volatile &; + using test = ct::add_member_const_t; + static_assert(std::is_same::value, ""); + } { + // add_member_const_t can also be used with "abominable" + // function types. + using f = int(); + using expect = int() const; + using test = ct::add_member_const_t; + static_assert(std::is_same::value, ""); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/add_member_cv.cpp b/src/boost/libs/callable_traits/example/add_member_cv.cpp new file mode 100644 index 000000000..77997688e --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_member_cv.cpp @@ -0,0 +1,49 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_cv +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = void(foo::*)(); + using expect = void(foo::*)() const volatile; + using test = ct::add_member_cv_t; + static_assert(std::is_same::value, ""); + } { + // add_member_cv_t doesn't change anything when + // the function type is already cv-qualified. + using pmf = void(foo::*)() const volatile &&; + using expect = void(foo::*)() const volatile &&; + using test = ct::add_member_cv_t; + static_assert(std::is_same::value, ""); + } { + using pmf = void(foo::*)() volatile &; + using expect = void(foo::*)() const volatile &; + using test = ct::add_member_cv_t; + static_assert(std::is_same::value, ""); + } { + // add_member_cv_t can also be used with "abominable" + // function types. + using f = void(); + using expect = void() const volatile; + using test = ct::add_member_cv_t; + static_assert(std::is_same::value, ""); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/add_member_lvalue_reference.cpp b/src/boost/libs/callable_traits/example/add_member_lvalue_reference.cpp new file mode 100644 index 000000000..8d168a295 --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_member_lvalue_reference.cpp @@ -0,0 +1,53 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_lvalue_reference +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = void(foo::*)(); + using expect = void(foo::*)() &; + using test = ct::add_member_lvalue_reference_t; + static_assert(std::is_same::value, ""); + } { + // add_member_lvalue_reference_t doesn't change anything when + // the function type already has an lvalue qualifier. + using pmf = void(foo::*)() &; + using expect = void(foo::*)() &; + using test = ct::add_member_lvalue_reference_t; + static_assert(std::is_same::value, ""); + } { + // add_member_lvalue_reference_t models C++11 reference collapsing + // rules, so that adding an lvalue qualifier to an + // rvalue-qualified type will force the lvalue. + using pmf = void(foo::*)() &&; + using expect = void(foo::*)() &; + using test = ct::add_member_lvalue_reference_t; + static_assert(std::is_same::value, ""); + } { + // add_member_lvalue_reference_t can also be used to create "abominable" + // function types. + using f = void(); + using expect = void() &; + using test = ct::add_member_lvalue_reference_t; + static_assert(std::is_same::value, ""); + } +} + +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/add_member_rvalue_reference.cpp b/src/boost/libs/callable_traits/example/add_member_rvalue_reference.cpp new file mode 100644 index 000000000..81ecf257c --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_member_rvalue_reference.cpp @@ -0,0 +1,53 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_rvalue_reference +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = void(foo::*)(); + using expect = void(foo::*)() &&; + using test = ct::add_member_rvalue_reference_t; + static_assert(std::is_same::value, ""); + } { + // add_member_rvalue_reference_t doesn't change anything when + // the function type already has an rvalue qualifier. + using pmf = void(foo::*)() &&; + using expect = void(foo::*)() &&; + using test = ct::add_member_rvalue_reference_t; + static_assert(std::is_same::value, ""); + } { + // add_member_rvalue_reference_t models C++11 reference collapsing + // rules, so that adding an rvalue qualifier to an + // lvalue-qualified type will not change anything. + using pmf = void(foo::*)() const &; + using expect = void(foo::*)() const &; + using test = ct::add_member_rvalue_reference_t; + static_assert(std::is_same::value, ""); + } { + // add_member_rvalue_reference_t can also be used with "abominable" + // function types. + using f = void() const; + using expect = void() const &&; + using test = ct::add_member_rvalue_reference_t; + static_assert(std::is_same::value, ""); + } +} + +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/add_member_volatile.cpp b/src/boost/libs/callable_traits/example/add_member_volatile.cpp new file mode 100644 index 000000000..ffddcbfe5 --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_member_volatile.cpp @@ -0,0 +1,50 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_volatile +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = void(foo::*)(); + using expect = void(foo::*)() volatile; + using test = ct::add_member_volatile_t; + static_assert(std::is_same::value, ""); + } { + // add_member_volatile_t doesn't change anything when + // the function type is already volatile. + using pmf = void(foo::*)() volatile &&; + using expect = void(foo::*)() volatile &&; + using test = ct::add_member_volatile_t; + static_assert(std::is_same::value, ""); + } { + using pmf = void(foo::*)() const &; + using expect = void(foo::*)() const volatile &; + using test = ct::add_member_volatile_t; + static_assert(std::is_same::value, ""); + } { + // add_member_volatile_t can also be used with "abominable" + // function types. + using f = void(); + using expect = void() volatile; + using test = ct::add_member_volatile_t; + static_assert(std::is_same::value, ""); + } +} + +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/add_noexcept.cpp b/src/boost/libs/callable_traits/example/add_noexcept.cpp new file mode 100644 index 000000000..fa5ff9066 --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_noexcept.cpp @@ -0,0 +1,29 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +//[ add_noexcept +#include +#include + +using boost::callable_traits::add_noexcept_t; + +static_assert(std::is_same< + add_noexcept_t, + int() noexcept +>{}, ""); + +int main() {} + +//] +#endif + diff --git a/src/boost/libs/callable_traits/example/add_transaction_safe.cpp b/src/boost/libs/callable_traits/example/add_transaction_safe.cpp new file mode 100644 index 000000000..92a6ea717 --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_transaction_safe.cpp @@ -0,0 +1,30 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +//[ add_transaction_safe +#include +#include + +using boost::callable_traits::add_transaction_safe_t; + +using not_safe = int(); +using safe = int() transaction_safe; +using safe_added = add_transaction_safe_t; + +static_assert(std::is_same{}, ""); + +int main() {} + +//] +#endif + diff --git a/src/boost/libs/callable_traits/example/add_varargs.cpp b/src/boost/libs/callable_traits/example/add_varargs.cpp new file mode 100644 index 000000000..8538c00bd --- /dev/null +++ b/src/boost/libs/callable_traits/example/add_varargs.cpp @@ -0,0 +1,44 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +//[ add_varargs +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using f = void(int); + using expect = void(int, ...); + using test = ct::add_varargs_t; + static_assert(std::is_same::value, ""); + } { + using fp = void(*)(); + using expect = void(*)(...); + using test = ct::add_varargs_t; + static_assert(std::is_same::value, ""); + } { + using fr = void(&)(const char*); + using expect = void(&)(const char*, ...); + using test = ct::add_varargs_t; + static_assert(std::is_same::value, ""); + } { + using pmf = void(foo::*)() const; + using expect = void(foo::*)(...) const; + using test = ct::add_varargs_t; + static_assert(std::is_same::value, ""); + + // add_varargs_t doesn't change anything when + // the type already has varargs. + using twice = ct::add_varargs_t; + static_assert(std::is_same::value, ""); + } +} +//] diff --git a/src/boost/libs/callable_traits/example/apply_member_pointer.cpp b/src/boost/libs/callable_traits/example/apply_member_pointer.cpp new file mode 100644 index 000000000..63a944d39 --- /dev/null +++ b/src/boost/libs/callable_traits/example/apply_member_pointer.cpp @@ -0,0 +1,94 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +//[ apply_member_pointer +#include +#include + +namespace ct = boost::callable_traits; + +struct foo; +struct bar; + +int main() { + + { + // function type -> member function pointer type + using f = int(int); + using g = ct::apply_member_pointer_t; + using expect = int(foo::*)(int); + static_assert(std::is_same::value, ""); + } + + { + // function pointer type (unqualified) -> member function pointer type + using f = int(*)(); + using g = ct::apply_member_pointer_t; + using expect = int(foo::*)(); + static_assert(std::is_same::value, ""); + } + + + { + // function pointer type (qualified) -> member data pointer type + + // Look out for cases like these two. If the input type to apply_member_pointer + // is a ``[*qualified]`` function pointer type, then the aliased type is a member data + // pointer to a ``[*qualified function pointer]``. + + { + using f = int(*&)(); + using g = ct::apply_member_pointer_t; + using expect = int (* foo::*)(); + static_assert(std::is_same::value, ""); + } + + { + using f = int(* const)(); + using g = ct::apply_member_pointer_t; + using expect = int (* const foo::*)(); + static_assert(std::is_same::value, ""); + } + } + + { + // function reference type -> member function pointer type + using f = void(&)(); + using g = ct::apply_member_pointer_t; + using expect = void(foo::*)(); + static_assert(std::is_same::value, ""); + } + + { + // member function pointer type -> member function pointer type + // (note the different parent class) + using f = int(bar::*)() const; + using g = ct::apply_member_pointer_t; + using expect = int(foo::*)() const; + static_assert(std::is_same::value, ""); + } + + { + // non-callable type -> member data pointer type + using g = ct::apply_member_pointer_t; + using expect = int foo::*; + static_assert(std::is_same::value, ""); + } + + + { + // function object type -> member data pointer type + // the same is true for lambdas and generic lambdas + auto lambda = [](){}; + using f = decltype(lambda); + using g = ct::apply_member_pointer_t; + using expect = f foo::*; + static_assert(std::is_same::value, ""); + } +} +//] + diff --git a/src/boost/libs/callable_traits/example/args.cpp b/src/boost/libs/callable_traits/example/args.cpp new file mode 100644 index 000000000..9e0ef2d9a --- /dev/null +++ b/src/boost/libs/callable_traits/example/args.cpp @@ -0,0 +1,69 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ args +#include +#include +#include + +namespace ct = boost::callable_traits; + +template +void test(){ + using args_t = ct::args_t; + static_assert(std::is_same::value, ""); +} + +int main() { + + { + auto lamda = [](int, float&, const char*){}; + using lam = decltype(lamda); + using expect = std::tuple; + + test(); + } + + { + struct foo; + using pmf = void(foo::*)(int, float&, const char*); + using expect = std::tuple; + + test(); + } + + { + using function_ptr = void(*)(int, float&, const char*); + using expect = std::tuple; + test(); + } + + { + using function_ref = void(&)(int, float&, const char*); + using expect = std::tuple; + test(); + } + + { + using function = void(int, float&, const char*); + using expect = std::tuple; + test(); + } + + { + using abominable = void(int, float&, const char*) const; + using expect = std::tuple; + test(); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS diff --git a/src/boost/libs/callable_traits/example/class_of.cpp b/src/boost/libs/callable_traits/example/class_of.cpp new file mode 100644 index 000000000..9a75977e1 --- /dev/null +++ b/src/boost/libs/callable_traits/example/class_of.cpp @@ -0,0 +1,22 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +//[ class_of +#include +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(std::is_same>::value, ""); +static_assert(std::is_same>::value, ""); + +int main() {} +//] diff --git a/src/boost/libs/callable_traits/example/function_type.cpp b/src/boost/libs/callable_traits/example/function_type.cpp new file mode 100644 index 000000000..8047bbb80 --- /dev/null +++ b/src/boost/libs/callable_traits/example/function_type.cpp @@ -0,0 +1,48 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ function_type +#include +#include + +namespace ct = boost::callable_traits; + +template +void test(){ + + // this example shows how boost::callable_traits::function_type_t + // bevaves consistently for many different types + using type = ct::function_type_t; + using expect = void(int, float&, const char*); + static_assert(std::is_same{}, ""); +} + +int main() { + + auto lamda = [](int, float&, const char*){}; + using lam = decltype(lamda); + test(); + + using function_ptr = void(*)(int, float&, const char*); + test(); + + using function_ref = void(&)(int, float&, const char*); + test(); + + using function = void(int, float&, const char*); + test(); + + using abominable = void(int, float&, const char*) const; + test(); +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS diff --git a/src/boost/libs/callable_traits/example/function_types_remove_const_comparison.cpp b/src/boost/libs/callable_traits/example/function_types_remove_const_comparison.cpp new file mode 100644 index 000000000..2f37f0922 --- /dev/null +++ b/src/boost/libs/callable_traits/example/function_types_remove_const_comparison.cpp @@ -0,0 +1,21 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +//[ function_types_remove_const_comparison +#include +#include + +struct foo { + void bar() const {} +}; + +using const_removed = boost::callable_traits::remove_member_const_t; + +static_assert(std::is_same::value, ""); + +int main(){} + +//] diff --git a/src/boost/libs/callable_traits/example/has_member_qualifiers.cpp b/src/boost/libs/callable_traits/example/has_member_qualifiers.cpp new file mode 100644 index 000000000..79378c3a3 --- /dev/null +++ b/src/boost/libs/callable_traits/example/has_member_qualifiers.cpp @@ -0,0 +1,21 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +//[ has_member_qualifiers +#include +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::has_member_qualifiers::value, ""); +static_assert(ct::has_member_qualifiers::value, ""); +static_assert(!ct::has_member_qualifiers::value, ""); + +int main() {} +//] diff --git a/src/boost/libs/callable_traits/example/has_varargs.cpp b/src/boost/libs/callable_traits/example/has_varargs.cpp new file mode 100644 index 000000000..1dd66fd44 --- /dev/null +++ b/src/boost/libs/callable_traits/example/has_varargs.cpp @@ -0,0 +1,24 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#ifdef BOOST_CLBL_TRTS_MSVC +// MSVC requires __cdecl for varargs, and I don't want to clutter the example +int main(){} +#else + +//[ has_varargs +#include +#include + +namespace ct = boost::callable_traits; + +static_assert(ct::has_varargs::value, ""); +static_assert(!ct::has_varargs::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/has_void_return.cpp b/src/boost/libs/callable_traits/example/has_void_return.cpp new file mode 100644 index 000000000..3e14561a2 --- /dev/null +++ b/src/boost/libs/callable_traits/example/has_void_return.cpp @@ -0,0 +1,18 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +//[ has_void_return +#include +#include + +namespace ct = boost::callable_traits; + +static_assert(ct::has_void_return::value, ""); +static_assert(!ct::has_void_return::value, ""); + +int main() {} +//] diff --git a/src/boost/libs/callable_traits/example/intro.cpp b/src/boost/libs/callable_traits/example/intro.cpp new file mode 100644 index 000000000..a1e05096d --- /dev/null +++ b/src/boost/libs/callable_traits/example/intro.cpp @@ -0,0 +1,62 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES +int main(){ return 0; } +#else + +//[ intro +#include +#include +#include + +namespace ct = boost::callable_traits; + +// This function template helps keep our example code neat +template +void assert_same(){ static_assert(std::is_same::value, ""); } + +// foo is a function object +struct foo { + void operator()(int, char, float) const {} +}; + +int main() { + + // Use args_t to retrieve a parameter list as a std::tuple: + assert_same< + ct::args_t, + std::tuple + >(); + + // has_void_return lets us perform a quick check for a void return type + static_assert(ct::has_void_return::value, ""); + + // Detect C-style variadics (ellipses) in a signature (e.g. printf) + static_assert(!ct::has_varargs::value, ""); + + // pmf is a pointer-to-member function: void (foo::*)(int, char, float) const + using pmf = decltype(&foo::operator()); + + // remove_member_const_t lets you remove the const member qualifier + assert_same< + ct::remove_member_const_t, + void (foo::*)(int, char, float) /*no const!*/ + >(); + + // Conversely, add_member_const_t adds a const member qualifier + assert_same< + pmf, + ct::add_member_const_t + >(); + + // is_const_member_v checks for the presence of member const + static_assert(ct::is_const_member::value, ""); +} + +//] +#endif diff --git a/src/boost/libs/callable_traits/example/is_const_member.cpp b/src/boost/libs/callable_traits/example/is_const_member.cpp new file mode 100644 index 000000000..110e76309 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_const_member.cpp @@ -0,0 +1,20 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +//[ is_const_member +#include +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_const_member::value, ""); +static_assert(!ct::is_const_member::value, ""); + +int main() {} +//] diff --git a/src/boost/libs/callable_traits/example/is_cv_member.cpp b/src/boost/libs/callable_traits/example/is_cv_member.cpp new file mode 100644 index 000000000..638c219e4 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_cv_member.cpp @@ -0,0 +1,22 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +//[ is_cv_member +#include +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_cv_member::value, ""); +static_assert(!ct::is_cv_member::value, ""); +static_assert(!ct::is_cv_member::value, ""); +static_assert(!ct::is_cv_member::value, ""); + +int main() {} +//] diff --git a/src/boost/libs/callable_traits/example/is_invocable.cpp b/src/boost/libs/callable_traits/example/is_invocable.cpp new file mode 100644 index 000000000..a374de01f --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_invocable.cpp @@ -0,0 +1,24 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +//[ is_invocable +#include +#include + +namespace ct = boost::callable_traits; + +struct foo { + template + typename std::enable_if::value>::type + operator()(T){} +}; + +static_assert(ct::is_invocable::value, ""); +static_assert(!ct::is_invocable::value, ""); + +int main() {} +//] diff --git a/src/boost/libs/callable_traits/example/is_lvalue_reference_member.cpp b/src/boost/libs/callable_traits/example/is_lvalue_reference_member.cpp new file mode 100644 index 000000000..4cc96e850 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_lvalue_reference_member.cpp @@ -0,0 +1,32 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ is_lvalue_reference_member +#include +#include + +namespace ct = boost::callable_traits; + +static_assert(ct::is_lvalue_reference_member::value, ""); +static_assert(!ct::is_lvalue_reference_member::value, ""); +static_assert(!ct::is_lvalue_reference_member::value, ""); + +struct foo; + +static_assert(ct::is_lvalue_reference_member::value, ""); +static_assert(!ct::is_lvalue_reference_member::value, ""); +static_assert(!ct::is_lvalue_reference_member::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/is_noexcept.cpp b/src/boost/libs/callable_traits/example/is_noexcept.cpp new file mode 100644 index 000000000..0c4e83887 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_noexcept.cpp @@ -0,0 +1,33 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +//[ is_noexcept +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_noexcept::value, ""); +static_assert(ct::is_noexcept::value, ""); +static_assert(ct::is_noexcept::value, ""); +static_assert(ct::is_noexcept::value, ""); + +static_assert(!ct::is_noexcept::value, ""); +static_assert(!ct::is_noexcept::value, ""); +static_assert(!ct::is_noexcept::value, ""); +static_assert(!ct::is_noexcept::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/is_reference_member.cpp b/src/boost/libs/callable_traits/example/is_reference_member.cpp new file mode 100644 index 000000000..480fb5588 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_reference_member.cpp @@ -0,0 +1,32 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ is_reference_member +#include +#include + +namespace ct = boost::callable_traits; + +static_assert(ct::is_reference_member::value, ""); +static_assert(ct::is_reference_member::value, ""); +static_assert(!ct::is_reference_member::value, ""); + +struct foo; + +static_assert(ct::is_reference_member::value, ""); +static_assert(ct::is_reference_member::value, ""); +static_assert(!ct::is_reference_member::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/is_rvalue_reference_member.cpp b/src/boost/libs/callable_traits/example/is_rvalue_reference_member.cpp new file mode 100644 index 000000000..162c12375 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_rvalue_reference_member.cpp @@ -0,0 +1,32 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ is_rvalue_reference_member +#include +#include + +namespace ct = boost::callable_traits; + +static_assert(ct::is_rvalue_reference_member::value, ""); +static_assert(!ct::is_rvalue_reference_member::value, ""); +static_assert(!ct::is_rvalue_reference_member::value, ""); + +struct foo; + +static_assert(ct::is_rvalue_reference_member::value, ""); +static_assert(!ct::is_rvalue_reference_member::value, ""); +static_assert(!ct::is_rvalue_reference_member::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/is_transaction_safe.cpp b/src/boost/libs/callable_traits/example/is_transaction_safe.cpp new file mode 100644 index 000000000..26ae8d9b4 --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_transaction_safe.cpp @@ -0,0 +1,33 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +//[ is_transaction_safe +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_transaction_safe::value, ""); +static_assert(ct::is_transaction_safe::value, ""); +static_assert(ct::is_transaction_safe::value, ""); +static_assert(ct::is_transaction_safe::value, ""); + +static_assert(!ct::is_transaction_safe::value, ""); +static_assert(!ct::is_transaction_safe::value, ""); +static_assert(!ct::is_transaction_safe::value, ""); +static_assert(!ct::is_transaction_safe::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/is_volatile_member.cpp b/src/boost/libs/callable_traits/example/is_volatile_member.cpp new file mode 100644 index 000000000..91dd3993c --- /dev/null +++ b/src/boost/libs/callable_traits/example/is_volatile_member.cpp @@ -0,0 +1,32 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ is_volatile_member +#include +#include + +namespace ct = boost::callable_traits; + +static_assert(ct::is_volatile_member::value, ""); +static_assert(ct::is_volatile_member::value, ""); +static_assert(!ct::is_volatile_member::value, ""); + +struct foo; + +static_assert(ct::is_volatile_member::value, ""); +static_assert(!ct::is_volatile_member::value, ""); +static_assert(!ct::is_volatile_member::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/overview.cpp b/src/boost/libs/callable_traits/example/overview.cpp new file mode 100644 index 000000000..a5186bf9c --- /dev/null +++ b/src/boost/libs/callable_traits/example/overview.cpp @@ -0,0 +1,78 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){} +#else + +//[ overview +#include + +#include +#include + +using std::is_same; +using std::tuple; + +using namespace boost::callable_traits; + +struct number { + int value; + int add(int n) const { return value + n; } +}; + +using pmf = decltype(&number::add); + +//` Manipulate member functions pointers with ease: +static_assert(is_same< + remove_member_const_t, + int(number::*)(int) +>{}, ""); + +static_assert(is_same< + add_member_volatile_t, + int(number::*)(int) const volatile +>{}, ""); + +static_assert(is_same< + class_of_t, + number +>{}, ""); + +//` INVOKE-aware metafunctions: + +static_assert(is_same< + args_t, + tuple +>{}, ""); + +static_assert(is_same< + return_type_t, + int +>{}, ""); + +static_assert(is_same< + function_type_t, + int(const number&, int) +>{}, ""); + +static_assert(is_same< + qualified_class_of_t, + const number& +>{}, ""); + +//` Here are a few other trait examples: +static_assert(is_const_member{}, ""); +static_assert(!is_volatile_member{}, ""); +static_assert(!has_void_return{}, ""); +static_assert(!has_varargs{}, ""); + +//] + +int main() {} + +#endif diff --git a/src/boost/libs/callable_traits/example/qualified_class_of.cpp b/src/boost/libs/callable_traits/example/qualified_class_of.cpp new file mode 100644 index 000000000..049f87e4f --- /dev/null +++ b/src/boost/libs/callable_traits/example/qualified_class_of.cpp @@ -0,0 +1,32 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ qualified_class_of +#include +#include + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(std::is_same>::value, ""); + +static_assert(std::is_same>::value, ""); + +static_assert(std::is_same>::value, ""); + +int main() {} +//] +#endif diff --git a/src/boost/libs/callable_traits/example/remove_member_const.cpp b/src/boost/libs/callable_traits/example/remove_member_const.cpp new file mode 100644 index 000000000..c0a97a5c4 --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_member_const.cpp @@ -0,0 +1,45 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_const +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = int(foo::*)() const; + using expect = int(foo::*)(); + using test = ct::remove_member_const_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() &&; + using test = ct::remove_member_const_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() const volatile &; + using expect = int(foo::*)() volatile &; + using test = ct::remove_member_const_t; + static_assert(std::is_same::value, ""); + } { + using f = int() const; + using expect = int(); + using test = ct::remove_member_const_t; + static_assert(std::is_same::value, ""); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/remove_member_cv.cpp b/src/boost/libs/callable_traits/example/remove_member_cv.cpp new file mode 100644 index 000000000..3d741fcca --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_member_cv.cpp @@ -0,0 +1,45 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_cv +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = int(foo::*)() const volatile; + using expect = int(foo::*)(); + using test = ct::remove_member_cv_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() &&; + using test = ct::remove_member_cv_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() const volatile &; + using expect = int(foo::*)() &; + using test = ct::remove_member_cv_t; + static_assert(std::is_same::value, ""); + } { + using f = int() const volatile; + using expect = int(); + using test = ct::remove_member_cv_t; + static_assert(std::is_same::value, ""); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/remove_member_reference.cpp b/src/boost/libs/callable_traits/example/remove_member_reference.cpp new file mode 100644 index 000000000..b08a8c6a2 --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_member_reference.cpp @@ -0,0 +1,45 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_reference +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = int(foo::*)() &; + using expect = int(foo::*)(); + using test = ct::remove_member_reference_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() const; + using test = ct::remove_member_reference_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() const volatile &; + using expect = int(foo::*)() const volatile; + using test = ct::remove_member_reference_t; + static_assert(std::is_same::value, ""); + } { + using f = int() &&; + using expect = int(); + using test = ct::remove_member_reference_t; + static_assert(std::is_same::value, ""); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/remove_member_volatile.cpp b/src/boost/libs/callable_traits/example/remove_member_volatile.cpp new file mode 100644 index 000000000..2d3fa388d --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_member_volatile.cpp @@ -0,0 +1,45 @@ +/*<- +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_volatile +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = int(foo::*)() const volatile; + using expect = int(foo::*)() const; + using test = ct::remove_member_volatile_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() volatile &&; + using expect = int(foo::*)() &&; + using test = ct::remove_member_volatile_t; + static_assert(std::is_same::value, ""); + } { + using pmf = int(foo::*)() volatile &; + using expect = int(foo::*)() &; + using test = ct::remove_member_volatile_t; + static_assert(std::is_same::value, ""); + } { + using f = int() const volatile; + using expect = int() const; + using test = ct::remove_member_volatile_t; + static_assert(std::is_same::value, ""); + } +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/example/remove_noexcept.cpp b/src/boost/libs/callable_traits/example/remove_noexcept.cpp new file mode 100644 index 000000000..d3b11c5e6 --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_noexcept.cpp @@ -0,0 +1,29 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +//[ remove_noexcept +#include +#include + +using boost::callable_traits::remove_noexcept_t; + +static_assert(std::is_same< + remove_noexcept_t, + int() +>{}, ""); + +int main() {} + +//] +#endif + diff --git a/src/boost/libs/callable_traits/example/remove_transaction_safe.cpp b/src/boost/libs/callable_traits/example/remove_transaction_safe.cpp new file mode 100644 index 000000000..bdf4f1340 --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_transaction_safe.cpp @@ -0,0 +1,29 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +//[ remove_transaction_safe +#include +#include + +namespace ct = boost::callable_traits; + +using ts = int() transaction_safe; +using not_ts = int(); +using ts_removed = ct::remove_transaction_safe_t; + +static_assert(std::is_same{}, ""); + +int main() {} +//] +#endif //#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + diff --git a/src/boost/libs/callable_traits/example/remove_varargs.cpp b/src/boost/libs/callable_traits/example/remove_varargs.cpp new file mode 100644 index 000000000..47194e08c --- /dev/null +++ b/src/boost/libs/callable_traits/example/remove_varargs.cpp @@ -0,0 +1,41 @@ +/*<- + +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +->*/ + +//[ remove_varargs +#include +#include + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using f = void(int, ...); + using expect = void(int); + using test = ct::remove_varargs_t; + static_assert(std::is_same::value, ""); + } { + using fp = void(*)(...); + using expect = void(*)(); + using test = ct::remove_varargs_t; + static_assert(std::is_same::value, ""); + } { + using fr = void(&)(const char*, ...); + using expect = void(&)(const char*); + using test = ct::remove_varargs_t; + static_assert(std::is_same::value, ""); + } { + using pmf = void(foo::*)(...) const; + using expect = void(foo::*)() const; + using test = ct::remove_varargs_t; + static_assert(std::is_same::value, ""); + } +} +//] diff --git a/src/boost/libs/callable_traits/example/return_type.cpp b/src/boost/libs/callable_traits/example/return_type.cpp new file mode 100644 index 000000000..bc3a5cef4 --- /dev/null +++ b/src/boost/libs/callable_traits/example/return_type.cpp @@ -0,0 +1,42 @@ +/*!<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ return_type +#include +#include + +namespace ct = boost::callable_traits; + +using expect = int; + +struct foo; + +template +void test() { + using result = ct::return_type_t; + static_assert(std::is_same{}, ""); +} + +int main() { + + test(); + test(); + test(); + test(); + test(); + + auto x = []() -> int { return 0; }; + + test(); +} +//] +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS diff --git a/src/boost/libs/callable_traits/example/void.cpp b/src/boost/libs/callable_traits/example/void.cpp new file mode 100644 index 000000000..75fc8eee2 --- /dev/null +++ b/src/boost/libs/callable_traits/example/void.cpp @@ -0,0 +1,31 @@ +/* + +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include +#include + +struct foo { + void operator()() const {} +}; + +namespace ct = boost::callable_traits; + +int main() { + + using args = ct::args_t; + using expected_args = std::tuple<>; + static_assert(std::is_same{}, ""); + + using signature = ct::function_type_t; + using expected_signature = void(); + static_assert(std::is_same{}, ""); + + return 0; +} diff --git a/src/boost/libs/callable_traits/index.html b/src/boost/libs/callable_traits/index.html new file mode 100644 index 000000000..1be116532 --- /dev/null +++ b/src/boost/libs/callable_traits/index.html @@ -0,0 +1,18 @@ + + + + + + + + Automatic redirection failed, click this link +
+

Copyright Louis Dionne, 2013-2016

+

Copyright Modified Work Barrett Adair, 2013-2016

+

+ Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE.md or copy at + www.boost.org/LICENSE_1_0.txt) +

+ + diff --git a/src/boost/libs/callable_traits/meta/libraries.json b/src/boost/libs/callable_traits/meta/libraries.json new file mode 100644 index 000000000..74423d39b --- /dev/null +++ b/src/boost/libs/callable_traits/meta/libraries.json @@ -0,0 +1,10 @@ +{ + "key": "callable_traits", + "name": "CallableTraits", + "authors": [ "Barrett Adair" ], + "maintainers": [ "Barrett Adair " ], + "description": "A spiritual successor to Boost.FunctionTypes, Boost.CallableTraits is a header-only C++11 library for the compile-time inspection and manipulation of all 'callable' types. Additional support for C++17 features.", + "category": [ + "Metaprogramming" + ] +} diff --git a/src/boost/libs/callable_traits/scripts/wandbox_deploy.py b/src/boost/libs/callable_traits/scripts/wandbox_deploy.py new file mode 100755 index 000000000..00af8eba4 --- /dev/null +++ b/src/boost/libs/callable_traits/scripts/wandbox_deploy.py @@ -0,0 +1,119 @@ +#! /usr/bin/env python + +# This script uploads a directory to Wandbox (http://melpon.org/wandbox), +# which is an online compiler environment, and prints a permalink to the +# uploaded code. We use this to provide a "Try it online" version of the +# library to make the barrier to entry as low as possible. +# +# This script was adapted from the script proposed in +# https://github.com/melpon/wandbox/issues/153. +# +# To know how to use this script: ./wandbox.py --help +# +# Copyright Louis Dionne 2013-2016 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +import argparse +import fnmatch +import json +import os +import re +import urllib2 + + +# Strips C and C++ comments from the given string. +# +# Copied from http://stackoverflow.com/a/241506/627587. +def strip_comments(text): + def replacer(match): + s = match.group(0) + if s.startswith('/'): + return " " # note: a space and not an empty string + else: + return s + pattern = re.compile( + r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', + re.DOTALL | re.MULTILINE + ) + return re.sub(pattern, replacer, text) + + +# Post the given JSON data to Wandbox's API, and return the result +# as a JSON object. +def upload(options): + request = urllib2.Request('https://wandbox.org/api/compile.json') + request.add_header('Content-Type', 'application/json') + response = urllib2.urlopen(request, json.dumps(options)) + return json.loads(response.read()) + + +# Returns a list of the '.hpp' headers in the given directory and in +# subdirectories. +# +# The path must be absolute, and the returned paths are all absolute too. +def headers(path): + return [ + os.path.join(dir, file) + for (dir, _, files) in os.walk(path) + for file in fnmatch.filter(files, "*.hpp") + ] + + +def main(): + parser = argparse.ArgumentParser(description= + """Upload a directory to Wandbox (http://melpon.org/wandbox). + + On success, the program prints a permalink to the uploaded + directory on Wandbox and returns 0. On error, it prints the + response from the Wandbox API and returns 1. + + Note that the comments are stripped from all the headers in the + uploaded directory. + """ + ) + parser.add_argument('directory', type=str, help= + """A directory to upload to Wandbox. + + The path may be either absolute or relative to the current directory. + However, the names of the files uploaded to Wandbox will all be + relative to this directory. This way, one can easily specify the + directory to be '/some/project/include', and the uploaded files + will be uploaded as-if they were rooted at '/some/project/include' + """) + parser.add_argument('main', type=str, help= + """The main source file. + + The path may be either absolute or relative to the current directory. + """ + ) + args = parser.parse_args() + directory = os.path.abspath(args.directory) + if not os.path.exists(directory): + raise Exception("'%s' is not a valid directory" % args.directory) + + cpp = os.path.abspath(args.main) + if not os.path.exists(cpp): + raise Exception("'%s' is not a valid file name" % args.main) + + response = upload({ + 'code': open(cpp).read(), + 'codes': [{ + 'file': os.path.relpath(header, directory).replace('\\', '/'), + 'code': strip_comments(open(header).read()) + } for header in headers(directory)], + 'options': 'warning,c++14', + 'compiler': 'clang-3.6.0', + 'save': True, + 'compiler-option-raw': '-I.' + }) + + if response['status'] == '0': + print response['url'] + return 0 + else: + print response + return 1 + + +exit(main()) diff --git a/src/boost/libs/callable_traits/test/CMakeLists.txt b/src/boost/libs/callable_traits/test/CMakeLists.txt new file mode 100644 index 000000000..640a787c7 --- /dev/null +++ b/src/boost/libs/callable_traits/test/CMakeLists.txt @@ -0,0 +1,41 @@ + +# Copyright Louis Dionne 2015 +# Modified Work Copyright Barrett Adair 2015-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +add_custom_target(tests COMMENT "Build all the unit tests.") +add_custom_target(tests.quick COMMENT "Build a subset of all the unit tests to finish faster.") + +############################################################################## +# callable_traits_add_unit_test( ...) +# +# Equivalent to `callable_traits_add_test`, except the test is also added as a +# dependency of the `tests` target. +############################################################################## + +function(boost_callable_traits_add_unit_test name) + boost_callable_traits_add_test(${ARGV}) + add_dependencies(tests ${name}) + if ((NOT "${name}" MATCHES "\\.ext\\.") AND (NOT "${name}" MATCHES "_mcd")) + add_dependencies(tests.quick ${name}) + endif() +endfunction() + +include_directories(${boost_callable_traits_SOURCE_DIR}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}) + +file(GLOB_RECURSE UNIT_TESTS "*.cpp") + +foreach(_file IN LISTS UNIT_TESTS) + boost_callable_traits_target_name_for(_target "${_file}") + add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") + set(lazy_target "lazy_${_target}") + add_executable(${lazy_target} EXCLUDE_FROM_ALL "${_file}") + target_compile_definitions(${lazy_target} INTERFACE -DUSE_LAZY_TYPES) + boost_callable_traits_add_unit_test(${_target} ${CMAKE_CURRENT_BINARY_DIR}/${_target}) + boost_callable_traits_add_unit_test(${lazy_target} ${CMAKE_CURRENT_BINARY_DIR}/${_target}) +endforeach() + +add_dependencies(callable_traits_check tests) diff --git a/src/boost/libs/callable_traits/test/Jamfile.v2 b/src/boost/libs/callable_traits/test/Jamfile.v2 new file mode 100644 index 000000000..bce5f2312 --- /dev/null +++ b/src/boost/libs/callable_traits/test/Jamfile.v2 @@ -0,0 +1,22 @@ +# Copyright Louis Dionne 2013-2016 +# Modified Work Copyright Barrett Adair 2016-2017 +# Copyright 2017 Peter Dimov +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +import testing ; +import ../../config/checks/config : requires ; + +project : + requirements + [ requires cxx11_constexpr ] + clang:"-pedantic -Wall -Wextra" + darwin:"-pedantic -Wall -Wextra" +; + +for local source in [ glob *.cpp ] +{ + run $(source) ; + run $(source) : : : USE_LAZY_TYPES : $(source:B)__lazy ; +} diff --git a/src/boost/libs/callable_traits/test/add_member_const.cpp b/src/boost/libs/callable_traits/test/add_member_const.cpp new file mode 100644 index 000000000..5a5faed3e --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_member_const.cpp @@ -0,0 +1,103 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +int main() { + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) LREF; + using r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) RREF ; + using c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const LREF; + using cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const RREF; + using v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile LREF; + using vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile RREF; + using cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile LREF; + using cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(int, int); + using l = void(foo::*)(int, int) LREF; + using r = void(foo::*)(int, int) RREF ; + using c = void(foo::*)(int, int) const; + using cl = void(foo::*)(int, int) const LREF; + using cr = void(foo::*)(int, int) const RREF; + using v = void(foo::*)(int, int) volatile; + using vl = void(foo::*)(int, int) volatile LREF; + using vr = void(foo::*)(int, int) volatile RREF; + using cv = void(foo::*)(int, int) const volatile; + using cvl = void(foo::*)(int, int) const volatile LREF; + using cvr = void(foo::*)(int, int) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +} diff --git a/src/boost/libs/callable_traits/test/add_member_cv.cpp b/src/boost/libs/callable_traits/test/add_member_cv.cpp new file mode 100644 index 000000000..cb4e04f5e --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_member_cv.cpp @@ -0,0 +1,104 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +int main() { + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) LREF; + using r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) RREF; + using c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const LREF; + using cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const RREF; + using v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile LREF; + using vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile RREF; + using cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile LREF; + using cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(int, int); + using l = void(foo::*)(int, int) LREF; + using r = void(foo::*)(int, int) RREF; + using c = void(foo::*)(int, int) const; + using cl = void(foo::*)(int, int) const LREF; + using cr = void(foo::*)(int, int) const RREF; + using v = void(foo::*)(int, int) volatile; + using vl = void(foo::*)(int, int) volatile LREF; + using vr = void(foo::*)(int, int) volatile RREF; + using cv = void(foo::*)(int, int) const volatile; + using cvl = void(foo::*)(int, int) const volatile LREF; + using cvr = void(foo::*)(int, int) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +} diff --git a/src/boost/libs/callable_traits/test/add_member_lvalue_reference.cpp b/src/boost/libs/callable_traits/test/add_member_lvalue_reference.cpp new file mode 100644 index 000000000..b32075428 --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_member_lvalue_reference.cpp @@ -0,0 +1,206 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +struct foo{}; + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() &&; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + } + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) &; + using r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) &&; + using c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const &; + using cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const &&; + using v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile &; + using vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile &&; + using cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile &; + using cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + } + + { + using f = void(...); + using l = void(...) &; + using r = void(...) &&; + using c = void(...) const; + using cl = void(...) const &; + using cr = void(...) const &&; + using v = void(...) volatile; + using vl = void(...) volatile &; + using vr = void(...) volatile &&; + using cv = void(...) const volatile; + using cvl = void(...) const volatile &; + using cvr = void(...) const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + } + + #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + { + using f = void(...) transaction_safe; + using l = void(...) & transaction_safe; + using r = void(...) && transaction_safe; + using c = void(...) const transaction_safe; + using cl = void(...) const & transaction_safe; + using cr = void(...) const && transaction_safe; + using v = void(...) volatile transaction_safe; + using vl = void(...) volatile & transaction_safe; + using vr = void(...) volatile && transaction_safe; + using cv = void(...) const volatile transaction_safe; + using cvl = void(...) const volatile & transaction_safe; + using cvr = void(...) const volatile && transaction_safe; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + + } + #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + + #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES + { + using f = void(...) noexcept; + using l = void(...) & noexcept; + using r = void(...) && noexcept; + using c = void(...) const noexcept; + using cl = void(...) const & noexcept; + using cr = void(...) const && noexcept; + using v = void(...) volatile noexcept; + using vl = void(...) volatile & noexcept; + using vr = void(...) volatile && noexcept; + using cv = void(...) const volatile noexcept; + using cvl = void(...) const volatile & noexcept; + using cvr = void(...) const volatile && noexcept; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + } + #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES + + #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES + #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + { + using f = void(...) transaction_safe noexcept; + using l = void(...) & transaction_safe noexcept; + using r = void(...) && transaction_safe noexcept; + using c = void(...) const transaction_safe noexcept; + using cl = void(...) const & transaction_safe noexcept; + using cr = void(...) const && transaction_safe noexcept; + using v = void(...) volatile transaction_safe noexcept; + using vl = void(...) volatile & transaction_safe noexcept; + using vr = void(...) volatile && transaction_safe noexcept; + using cv = void(...) const volatile transaction_safe noexcept; + using cvl = void(...) const volatile & transaction_safe noexcept; + using cvr = void(...) const volatile && transaction_safe noexcept; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(!std::is_same{}); + } + #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +} + +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS + diff --git a/src/boost/libs/callable_traits/test/add_member_rvalue_reference.cpp b/src/boost/libs/callable_traits/test/add_member_rvalue_reference.cpp new file mode 100644 index 000000000..e7d3e8709 --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_member_rvalue_reference.cpp @@ -0,0 +1,167 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + + +struct foo{}; + +int main() { + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() &&; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() &&; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(...); + using l = void(foo::*)(...) &; + using r = void(foo::*)(...) &&; + using c = void(foo::*)(...) const; + using cl = void(foo::*)(...) const &; + using cr = void(foo::*)(...) const &&; + using v = void(foo::*)(...) volatile; + using vl = void(foo::*)(...) volatile &; + using vr = void(foo::*)(...) volatile &&; + using cv = void(foo::*)(...) const volatile; + using cvl = void(foo::*)(...) const volatile &; + using cvr = void(foo::*)(...) const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() &&; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(); + using l = void() &; + using r = void() &&; + using c = void() const; + using cl = void() const &; + using cr = void() const &&; + using v = void() volatile; + using vl = void() volatile &; + using vr = void() volatile &&; + using cv = void() const volatile; + using cvl = void() const volatile &; + using cvr = void() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(!std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } +} + +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/test/add_member_volatile.cpp b/src/boost/libs/callable_traits/test/add_member_volatile.cpp new file mode 100644 index 000000000..a76e02e6e --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_member_volatile.cpp @@ -0,0 +1,76 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo{}; + +int main() { + + { + using f = int(foo::*)(int); + using l = int(foo::*)(int) LREF; + using r = int(foo::*)(int) RREF; + using c = int(foo::*)(int) const; + using cl = int(foo::*)(int) const LREF; + using cr = int(foo::*)(int) const RREF; + using v = int(foo::*)(int) volatile; + using vl = int(foo::*)(int) volatile LREF; + using vr = int(foo::*)(int) volatile RREF; + using cv = int(foo::*)(int) const volatile; + using cvl = int(foo::*)(int) const volatile LREF; + using cvr = int(foo::*)(int) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = foo(); + using l = foo() LREF; + using r = foo() RREF; + using c = foo() const; + using cl = foo() const LREF; + using cr = foo() const RREF; + using v = foo() volatile; + using vl = foo() volatile LREF; + using vr = foo() volatile RREF; + using cv = foo() const volatile; + using cvl = foo() const volatile LREF; + using cvr = foo() const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#endif +} diff --git a/src/boost/libs/callable_traits/test/add_noexcept.cpp b/src/boost/libs/callable_traits/test/add_noexcept.cpp new file mode 100644 index 000000000..c13251a62 --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_noexcept.cpp @@ -0,0 +1,45 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +#include +#include "test.hpp" + +template +void test() { + + CT_ASSERT(std::is_same::value); + + //sanity check + CT_ASSERT(!std::is_same::value); +} + +#define TEST_NOEXCEPT(not_noexcept) test() + +int main() { + + TEST_NOEXCEPT(int(int) &); + TEST_NOEXCEPT(int(*)(int)); + TEST_NOEXCEPT(int(int, ...) &&); + TEST_NOEXCEPT(int(*)(int, ...)); + + struct foo; + + TEST_NOEXCEPT(int(foo::*)(int)); + TEST_NOEXCEPT(int(foo::*)(int) const); + TEST_NOEXCEPT(int(foo::*)(int, ...)); + TEST_NOEXCEPT(int(foo::*)(int, ...) volatile); +} + +#endif // #ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES + diff --git a/src/boost/libs/callable_traits/test/add_noexcept_constraints.cpp b/src/boost/libs/callable_traits/test/add_noexcept_constraints.cpp new file mode 100644 index 000000000..e6f59cb5a --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_noexcept_constraints.cpp @@ -0,0 +1,51 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +struct foo; + +template +struct is_substitution_failure_add_noexcept { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); + CT_ASSERT(is_substitution_failure_add_noexcept::value); +} + +#endif //#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE diff --git a/src/boost/libs/callable_traits/test/add_transaction_safe.cpp b/src/boost/libs/callable_traits/test/add_transaction_safe.cpp new file mode 100644 index 000000000..a02f00926 --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_transaction_safe.cpp @@ -0,0 +1,45 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +#include +#include "test.hpp" + +template +void test() { + + CT_ASSERT(std::is_same::value); + + //sanity check + CT_ASSERT(!std::is_same::value); +} + +#define TEST_TRANSACTION_SAFE(not_safe) test() + +int main() { + + TEST_TRANSACTION_SAFE(int(int) &); + TEST_TRANSACTION_SAFE(int(*)(int)); + TEST_TRANSACTION_SAFE(int(int, ...) &&); + TEST_TRANSACTION_SAFE(int(*)(int, ...)); + + struct foo; + + TEST_TRANSACTION_SAFE(int(foo::*)(int)); + TEST_TRANSACTION_SAFE(int(foo::*)(int) const); + TEST_TRANSACTION_SAFE(int(foo::*)(int, ...)); + TEST_TRANSACTION_SAFE(int(foo::*)(int, ...) volatile); +} + +#endif + diff --git a/src/boost/libs/callable_traits/test/add_transaction_safe_constraints.cpp b/src/boost/libs/callable_traits/test/add_transaction_safe_constraints.cpp new file mode 100644 index 000000000..bb74cdc19 --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_transaction_safe_constraints.cpp @@ -0,0 +1,51 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +struct foo; + +template +struct is_substitution_failure_add_tx_safe { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); + CT_ASSERT(is_substitution_failure_add_tx_safe::value); +} + +#endif //#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE diff --git a/src/boost/libs/callable_traits/test/add_varargs.cpp b/src/boost/libs/callable_traits/test/add_varargs.cpp new file mode 100644 index 000000000..c1d0ca05a --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_varargs.cpp @@ -0,0 +1,188 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() LREF; + using r = void(foo::*)() RREF ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const LREF; + using cr = void(foo::*)() const RREF; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile LREF; + using vr = void(foo::*)() volatile RREF; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile LREF; + using cvr = void(foo::*)() const volatile RREF; + + using va_f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using va_l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) LREF; + using va_r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) RREF ; + using va_c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using va_cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const LREF; + using va_cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const RREF; + using va_v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using va_vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile LREF; + using va_vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile RREF; + using va_cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using va_cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile LREF; + using va_cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(int&, int&&); + using l = void(foo::*)(int&, int&&) LREF; + using r = void(foo::*)(int&, int&&) RREF ; + using c = void(foo::*)(int&, int&&) const; + using cl = void(foo::*)(int&, int&&) const LREF; + using cr = void(foo::*)(int&, int&&) const RREF; + using v = void(foo::*)(int&, int&&) volatile; + using vl = void(foo::*)(int&, int&&) volatile LREF; + using vr = void(foo::*)(int&, int&&) volatile RREF; + using cv = void(foo::*)(int&, int&&) const volatile; + using cvl = void(foo::*)(int&, int&&) const volatile LREF; + using cvr = void(foo::*)(int&, int&&) const volatile RREF; + + using va_f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...); + using va_l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) LREF; + using va_r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) RREF ; + using va_c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const; + using va_cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const LREF; + using va_cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const RREF; + using va_v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) volatile; + using va_vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) volatile LREF; + using va_vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) volatile RREF; + using va_cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const volatile; + using va_cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const volatile LREF; + using va_cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + using va_f = void(...); + using va_l = void(...) LREF; + using va_r = void(...) RREF ; + using va_c = void(...) const; + using va_cl = void(...) const LREF; + using va_cr = void(...) const RREF; + using va_v = void(...) volatile; + using va_vl = void(...) volatile LREF; + using va_vr = void(...) volatile RREF; + using va_cv = void(...) const volatile; + using va_cvl = void(...) const volatile LREF; + using va_cvr = void(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(&)(); + using va_f = void(&)(...); + CT_ASSERT(std::is_same{}); + } +} diff --git a/src/boost/libs/callable_traits/test/add_varargs_constraints.cpp b/src/boost/libs/callable_traits/test/add_varargs_constraints.cpp new file mode 100644 index 000000000..baa63dcd1 --- /dev/null +++ b/src/boost/libs/callable_traits/test/add_varargs_constraints.cpp @@ -0,0 +1,45 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include "test.hpp" + +struct foo; + +template +struct is_substitution_failure_add_varargs { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); + CT_ASSERT(is_substitution_failure_add_varargs::value); +} diff --git a/src/boost/libs/callable_traits/test/apply_member_pointer_constraints.cpp b/src/boost/libs/callable_traits/test/apply_member_pointer_constraints.cpp new file mode 100644 index 000000000..3b896aa36 --- /dev/null +++ b/src/boost/libs/callable_traits/test/apply_member_pointer_constraints.cpp @@ -0,0 +1,32 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#include "test.hpp" + +struct foo; + +template +struct is_substitution_failure_apply_member_pointer { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + CT_ASSERT(is_substitution_failure_apply_member_pointer::value); + CT_ASSERT(is_substitution_failure_apply_member_pointer::value); + CT_ASSERT(is_substitution_failure_apply_member_pointer::value); +} + diff --git a/src/boost/libs/callable_traits/test/apply_member_pointer_function.cpp b/src/boost/libs/callable_traits/test/apply_member_pointer_function.cpp new file mode 100644 index 000000000..e09d47343 --- /dev/null +++ b/src/boost/libs/callable_traits/test/apply_member_pointer_function.cpp @@ -0,0 +1,114 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + + +#include +#include "test.hpp" + +struct foo; + +template +void test_case() { + assert_same(); +} + +int main() { + + test_case(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); +#endif + + test_case(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); +#endif + +//MSVC doesn't like varargs on abominable functions +#ifndef BOOST_CLBL_TRTS_MSVC + + test_case(); + + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + test_case(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +#endif //#ifndef BOOST_CLBL_TRTS_MSVC + +} diff --git a/src/boost/libs/callable_traits/test/apply_member_pointer_pmd.cpp b/src/boost/libs/callable_traits/test/apply_member_pointer_pmd.cpp new file mode 100644 index 000000000..9395ff493 --- /dev/null +++ b/src/boost/libs/callable_traits/test/apply_member_pointer_pmd.cpp @@ -0,0 +1,31 @@ +/*<- +Copyright (c) 2016 arett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + + +#include +#include "test.hpp" + +struct foo; + +template +void test_case() { + assert_same(); +} + +int main() { + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + + //member data - function pointer + test_case(); + test_case(); +} + diff --git a/src/boost/libs/callable_traits/test/apply_member_pointer_pmf.cpp b/src/boost/libs/callable_traits/test/apply_member_pointer_pmf.cpp new file mode 100644 index 000000000..8b9eaf220 --- /dev/null +++ b/src/boost/libs/callable_traits/test/apply_member_pointer_pmf.cpp @@ -0,0 +1,95 @@ +/*<- +Copyright (c) 2016 arett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + + +#include +#include "test.hpp" + +struct a; +struct b; + +template +void test_case() { + assert_same< TRAIT(apply_member_pointer, Input, b), Output>(); +} + +int main() { + + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); + test_case(); +} diff --git a/src/boost/libs/callable_traits/test/args.cpp b/src/boost/libs/callable_traits/test/args.cpp new file mode 100644 index 000000000..b3f5138a2 --- /dev/null +++ b/src/boost/libs/callable_traits/test/args.cpp @@ -0,0 +1,67 @@ +/* + +Copyright Barrett Adair 2015-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include +#include +#include "test.hpp" + + +struct foo1 { + int bar(char, float&, int = 0) { return{}; } +}; + +struct foo2 { + int bar(char, float&, int = 0, ...) { return{}; } +}; + +struct foo3 { + int operator()(char, float&, int = 0) { return{}; } +}; + +struct foo4 { + int operator()(char, float&, int = 0, ...) { return{}; } +}; + +int foo5(char, float&, int = 0) { return{}; } + +int foo6(char, float&, int = 0, ...) { return{}; } + +struct foo7 { + int bar() { return{}; } +}; + +using std::is_same; + +int main() { + + { + using pmf = decltype(&foo1::bar); + using args_t = TRAIT(args, pmf); + CT_ASSERT(is_same>{}); + } { + using pmf = decltype(&foo2::bar); + using args_t = TRAIT(args, pmf); + CT_ASSERT(is_same>{}); + } { + using args_t = TRAIT(args, foo3); + CT_ASSERT(is_same>{}); + } { + using args_t = TRAIT(args, foo4); + CT_ASSERT(is_same>{}); + } { + using args_t = TRAIT(args, decltype(foo5)); + CT_ASSERT(is_same>{}); + } { + using args_t = TRAIT(args, decltype(foo6)); + CT_ASSERT(is_same>{}); + } + + return 0; +} diff --git a/src/boost/libs/callable_traits/test/args_constraints.cpp b/src/boost/libs/callable_traits/test/args_constraints.cpp new file mode 100644 index 000000000..ef651cdb4 --- /dev/null +++ b/src/boost/libs/callable_traits/test/args_constraints.cpp @@ -0,0 +1,46 @@ + +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include "test.hpp" + +struct foo; + +template +struct is_substitution_failure_args { + + template + static auto test(...) -> std::true_type; + + template + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); + CT_ASSERT(!is_substitution_failure_args::value); + CT_ASSERT(!is_substitution_failure_args::value); + CT_ASSERT(!is_substitution_failure_args::value); + CT_ASSERT(!is_substitution_failure_args::value); + CT_ASSERT(!is_substitution_failure_args::value); + auto lambda = [](){}; + CT_ASSERT(!is_substitution_failure_args::value); + CT_ASSERT(is_substitution_failure_args::value); +} + diff --git a/src/boost/libs/callable_traits/test/class_of.cpp b/src/boost/libs/callable_traits/test/class_of.cpp new file mode 100644 index 000000000..2048a33f4 --- /dev/null +++ b/src/boost/libs/callable_traits/test/class_of.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include "test.hpp" + +struct foo; + +int main() { + + { + using f = void(foo::*)(); + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same::value); + } + + { + using f = void(foo::*)() const; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same::value); + } + + { + using f = void(foo::*)() volatile; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same::value); + } + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int, ...) const volatile; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same::value); + } + + { + using f = int foo::*; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same::value); + } + + { + using f = const int foo::*; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same::value); + } +} diff --git a/src/boost/libs/callable_traits/test/class_of_constraints.cpp b/src/boost/libs/callable_traits/test/class_of_constraints.cpp new file mode 100644 index 000000000..225a0359d --- /dev/null +++ b/src/boost/libs/callable_traits/test/class_of_constraints.cpp @@ -0,0 +1,45 @@ + +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include "test.hpp" + +struct foo; + +template +struct is_substitution_failure_class_of { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); + CT_ASSERT(is_substitution_failure_class_of::value); +} + diff --git a/src/boost/libs/callable_traits/test/collapse_flags.cpp b/src/boost/libs/callable_traits/test/collapse_flags.cpp new file mode 100644 index 000000000..9ad524483 --- /dev/null +++ b/src/boost/libs/callable_traits/test/collapse_flags.cpp @@ -0,0 +1,38 @@ + +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include "test.hpp" + + +using namespace boost::callable_traits; +using namespace boost::callable_traits::detail; + +int main() { + + // boost::callable_traits::detail::collapse_flags emulates the C++11 + // reference collapsing rules. Here, we test that behavior. + + using rref_plus_lref = collapse_flags; + CT_ASSERT(rref_plus_lref::value == lref_); + + using lref_plus_rref = collapse_flags; + CT_ASSERT(lref_plus_rref::value == lref_); + + using lref_plus_lref = collapse_flags; + CT_ASSERT(lref_plus_lref::value == lref_); + + using rref_plus_rref = collapse_flags; + CT_ASSERT(rref_plus_rref::value == rref_); + + using const_plus_rref = collapse_flags; + CT_ASSERT(const_plus_rref::value == (const_ | rref_)); + + using const_plus_lref = collapse_flags; + CT_ASSERT(const_plus_lref::value == (const_ | lref_)); +} diff --git a/src/boost/libs/callable_traits/test/function_type.cpp b/src/boost/libs/callable_traits/test/function_type.cpp new file mode 100644 index 000000000..98fa1af8c --- /dev/null +++ b/src/boost/libs/callable_traits/test/function_type.cpp @@ -0,0 +1,96 @@ + +#include +#include "test.hpp" + +int main() { + + struct foo; + + { + auto g = [](int, char){}; + using G = decltype(g); + using F = void(int, char); + CT_ASSERT(std::is_same::value); + CT_ASSERT(std::is_same, F>::value); + CT_ASSERT(std::is_same, F>::value); + CT_ASSERT(std::is_same, F>::value); + CT_ASSERT(std::is_same, F>::value); + CT_ASSERT(std::is_same, F>::value); + CT_ASSERT(std::is_same, void(G const &, int, char)>::value); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + { + using G = void (int, char, ...) const LREF; + using F = void (int, char, ...); + CT_ASSERT(std::is_same::value); + } +#endif + + { + using G = void (*)(int, char) BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER; + using F = void (int, char); + CT_ASSERT(std::is_same::value); + }{ + using G = void (* const &)(int, char); + using F = void (int, char); + CT_ASSERT(std::is_same::value); + }{ + using G = int (* &&)(); + using F = int (); + CT_ASSERT(std::is_same::value); + }{ + using G = int (* &&)(); + using F = int (); + CT_ASSERT(std::is_same::value); + }{ + using G = char const * const & (&)(...); + using F = char const * const & (...); + CT_ASSERT(std::is_same::value); + }{ + struct G { int operator() (...) volatile; }; + using F = int (...); + CT_ASSERT(std::is_same::value); + }{ + struct G { int operator() (...) volatile BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; }; + using F = int (...); + CT_ASSERT(std::is_same::value); + }{ + struct G { int operator() (...) const BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; }; + using F = int (...); + CT_ASSERT(std::is_same::value); + }{ + using G = void (foo::* const &)(int, int, int) LREF BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER; + using F = void (foo &, int, int, int); + CT_ASSERT(std::is_same::value); + } +#ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS + { + using G = void (foo::* const &)(int, int, int) RREF; + using F = void (foo &&, int, int, int); + CT_ASSERT(std::is_same::value); + } +#endif + { + using G = void (foo::*)(int, int, int) const BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER; + using F = void (foo const &, int, int, int); + CT_ASSERT(std::is_same::value); + }{ + using G = void (foo::*)(int, int, int); + using F = void (foo &, int, int, int); + CT_ASSERT(std::is_same::value); + }{ + using G = void (foo::*)() BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; + using F = void (foo &); + CT_ASSERT(std::is_same::value); + }{ + using G = void (foo::*)(int, int, int) const BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; + using F = void (foo const &, int, int, int); + CT_ASSERT(std::is_same::value); + }{ + using G = void (foo::*)(int, int, int, ...) const BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; + using F = void (foo const &, int, int, int, ...); + CT_ASSERT(std::is_same::value); + } +} diff --git a/src/boost/libs/callable_traits/test/function_type_constraints.cpp b/src/boost/libs/callable_traits/test/function_type_constraints.cpp new file mode 100644 index 000000000..99570dfed --- /dev/null +++ b/src/boost/libs/callable_traits/test/function_type_constraints.cpp @@ -0,0 +1,46 @@ + +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include "test.hpp" + +struct foo; + +template +struct is_substitution_failure_function_type { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + CT_ASSERT(is_substitution_failure_function_type::value); + CT_ASSERT(is_substitution_failure_function_type::value); + CT_ASSERT(is_substitution_failure_function_type::value); + CT_ASSERT(is_substitution_failure_function_type::value); + CT_ASSERT(is_substitution_failure_function_type::value); + CT_ASSERT(is_substitution_failure_function_type::value); + CT_ASSERT(!is_substitution_failure_function_type::value); + CT_ASSERT(!is_substitution_failure_function_type::value); + CT_ASSERT(!is_substitution_failure_function_type::value); + CT_ASSERT(!is_substitution_failure_function_type::value); + + auto lambda = [](){}; + CT_ASSERT(!is_substitution_failure_function_type::value); + CT_ASSERT(is_substitution_failure_function_type::value); +} + diff --git a/src/boost/libs/callable_traits/test/has_member_qualifiers.cpp b/src/boost/libs/callable_traits/test/has_member_qualifiers.cpp new file mode 100644 index 000000000..9f80c28b1 --- /dev/null +++ b/src/boost/libs/callable_traits/test/has_member_qualifiers.cpp @@ -0,0 +1,128 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main() { return 0; } +#else + +struct foo {}; + +template +void assert_qualified() { + CT_ASSERT( has_member_qualifiers::value); +} + + +template +void assert_unqualified() { + CT_ASSERT(! has_member_qualifiers::value); +} + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() && ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + assert_unqualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() & { return 0; } }; + struct r { int operator()() && { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const & { return 0; } }; + struct cr { int operator()() const && { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile & { return 0; } }; + struct vr { int operator()() volatile && { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile & { return 0; } }; + struct cvr { int operator()() const volatile && { return 0; } }; + + assert_unqualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() &; + using r = void() && ; + using c = void() const; + using cl = void() const &; + using cr = void() const &&; + using v = void() volatile; + using vl = void() volatile &; + using vr = void() volatile &&; + using cv = void() const volatile; + using cvl = void() const volatile &; + using cvr = void() const volatile &&; + + CT_ASSERT(! has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + CT_ASSERT( has_member_qualifiers()); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + using f_ptr = void(*)(); + assert_unqualified(); + assert_unqualified(); + assert_unqualified(); + assert_unqualified(); +} + +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/test/has_member_qualifiers_simple.cpp b/src/boost/libs/callable_traits/test/has_member_qualifiers_simple.cpp new file mode 100644 index 000000000..c6717c983 --- /dev/null +++ b/src/boost/libs/callable_traits/test/has_member_qualifiers_simple.cpp @@ -0,0 +1,58 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + + + +struct foo {}; + +template +void assert_qualified() { + CT_ASSERT( has_member_qualifiers::value); +} + +template +void assert_unqualified() { + CT_ASSERT(! has_member_qualifiers::value); +} + +int main() { + + { + using f = void(foo::*)(); + using c = void(foo::*)() const; + using v = void(foo::*)() volatile; + using cv = void(foo::*)() const volatile; + + assert_unqualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + + assert_unqualified(); + assert_qualified(); + assert_qualified(); + assert_qualified(); + } + + using f_ptr = void(*)(); + assert_unqualified(); + assert_unqualified(); + assert_unqualified(); + assert_unqualified(); +} diff --git a/src/boost/libs/callable_traits/test/has_varargs.cpp b/src/boost/libs/callable_traits/test/has_varargs.cpp new file mode 100644 index 000000000..b187a6fbb --- /dev/null +++ b/src/boost/libs/callable_traits/test/has_varargs.cpp @@ -0,0 +1,214 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +template +void assert_has_varargs() { + + CT_ASSERT( has_varargs::value); +} + +template +void assert_not_has_varargs() { + + CT_ASSERT(! has_varargs::value); +} + + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() LREF; + using r = void(foo::*)() RREF ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const LREF; + using cr = void(foo::*)() const RREF; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile LREF; + using vr = void(foo::*)() volatile RREF; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile LREF; + using cvr = void(foo::*)() const volatile RREF; + + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + } + + { + //a member data pointer to a function pointer + //is not treated like a member function pointer + using f_ptr = void(*)(...); + using f = f_ptr foo::*; + assert_not_has_varargs(); + } + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) LREF; + using r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) RREF ; + using c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const LREF; + using cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const RREF; + using v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile LREF; + using vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile RREF; + using cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile LREF; + using cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile RREF; + + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() LREF { return 0; } }; + struct r { int operator()() RREF { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const LREF { return 0; } }; + struct cr { int operator()() const RREF { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile LREF { return 0; } }; + struct vr { int operator()() volatile RREF { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile LREF { return 0; } }; + struct cvr { int operator()() const volatile RREF { return 0; } }; + + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + assert_not_has_varargs(); + } + + { + struct f { int operator()(...) { return 0; } }; + struct l { int operator()(...) LREF { return 0; } }; + struct r { int operator()(...) RREF { return 0; } }; + struct c { int operator()(...) const { return 0; } }; + struct cl { int operator()(...) const LREF { return 0; } }; + struct cr { int operator()(...) const RREF { return 0; } }; + struct v { int operator()(...) volatile { return 0; } }; + struct vl { int operator()(...) volatile LREF { return 0; } }; + struct vr { int operator()(...) volatile RREF { return 0; } }; + struct cv { int operator()(...) const volatile { return 0; } }; + struct cvl { int operator()(...) const volatile LREF { return 0; } }; + struct cvr { int operator()(...) const volatile RREF { return 0; } }; + + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + assert_has_varargs(); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + CT_ASSERT(! has_varargs()); + } + + { + using f = void(...); + using l = void(...) LREF; + using r = void(...) RREF ; + using c = void(...) const; + using cl = void(...) const LREF; + using cr = void(...) const RREF; + using v = void(...) volatile; + using vl = void(...) volatile LREF; + using vr = void(...) volatile RREF; + using cv = void(...) const volatile; + using cvl = void(...) const volatile LREF; + using cvr = void(...) const volatile RREF; + + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + CT_ASSERT( has_varargs()); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + assert_not_has_varargs(); + assert_has_varargs(); + assert_not_has_varargs(); + assert_has_varargs(); +} diff --git a/src/boost/libs/callable_traits/test/has_void_return.cpp b/src/boost/libs/callable_traits/test/has_void_return.cpp new file mode 100644 index 000000000..416ccdc1d --- /dev/null +++ b/src/boost/libs/callable_traits/test/has_void_return.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include "test.hpp" + +struct foo; + +template +void assert_void_return() { + CT_ASSERT(has_void_return::value); +} + +template +void assert_not_void_return() { + CT_ASSERT(!has_void_return::value); +} + +int main() { + + assert_void_return(); + assert_void_return(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + assert_void_return(); + assert_void_return(); + assert_void_return(); +#endif // #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + assert_void_return(); + assert_void_return(); + assert_void_return(); + assert_void_return(); + assert_void_return(); + + assert_void_return(); + assert_void_return(); + + assert_void_return(); + assert_void_return(); + + auto lambda = []{}; + assert_void_return(); + + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); + assert_not_void_return(); +} diff --git a/src/boost/libs/callable_traits/test/is_const_member.cpp b/src/boost/libs/callable_traits/test/is_const_member.cpp new file mode 100644 index 000000000..5f9c0490d --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_const_member.cpp @@ -0,0 +1,121 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +template +void assert_const_qualified() { + CT_ASSERT( is_const_member()); +} + + +template +void assert_not_const_qualified() { + CT_ASSERT(! is_const_member()); +} + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() LREF; + using r = void(foo::*)() RREF ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const LREF; + using cr = void(foo::*)() const RREF; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile LREF; + using vr = void(foo::*)() volatile RREF; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile LREF; + using cvr = void(foo::*)() const volatile RREF; + + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() LREF { return 0; } }; + struct r { int operator()() RREF { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const LREF { return 0; } }; + struct cr { int operator()() const RREF { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile LREF { return 0; } }; + struct vr { int operator()() volatile RREF { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile LREF { return 0; } }; + struct cvr { int operator()() const volatile RREF { return 0; } }; + + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + assert_const_qualified(); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(! is_const_member()); + CT_ASSERT(! is_const_member()); + CT_ASSERT(! is_const_member()); + CT_ASSERT( is_const_member()); + CT_ASSERT( is_const_member()); + CT_ASSERT( is_const_member()); + CT_ASSERT(! is_const_member()); + CT_ASSERT(! is_const_member()); + CT_ASSERT(! is_const_member()); + CT_ASSERT( is_const_member()); + CT_ASSERT( is_const_member()); + CT_ASSERT( is_const_member()); + } + +#endif + + using f_ptr = void(*)(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); + assert_not_const_qualified(); +} diff --git a/src/boost/libs/callable_traits/test/is_cv_member.cpp b/src/boost/libs/callable_traits/test/is_cv_member.cpp new file mode 100644 index 000000000..b1af75588 --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_cv_member.cpp @@ -0,0 +1,121 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +template +void assert_cv_qualified() { + CT_ASSERT( is_cv_member()); +} + + +template +void assert_not_cv_qualified() { + CT_ASSERT(! is_cv_member()); +} + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() LREF; + using r = void(foo::*)() RREF ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const LREF; + using cr = void(foo::*)() const RREF; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile LREF; + using vr = void(foo::*)() volatile RREF; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile LREF; + using cvr = void(foo::*)() const volatile RREF; + + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_cv_qualified(); + assert_cv_qualified(); + assert_cv_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() LREF { return 0; } }; + struct r { int operator()() RREF { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const LREF { return 0; } }; + struct cr { int operator()() const RREF { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile LREF { return 0; } }; + struct vr { int operator()() volatile RREF { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile LREF { return 0; } }; + struct cvr { int operator()() const volatile RREF { return 0; } }; + + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_cv_qualified(); + assert_cv_qualified(); + assert_cv_qualified(); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT(! is_cv_member()); + CT_ASSERT( is_cv_member()); + CT_ASSERT( is_cv_member()); + CT_ASSERT( is_cv_member()); + } + +#endif + + using f_ptr = void(*)(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); + assert_not_cv_qualified(); +} diff --git a/src/boost/libs/callable_traits/test/is_invocable.cpp b/src/boost/libs/callable_traits/test/is_invocable.cpp new file mode 100644 index 000000000..b9fa0ea4a --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_invocable.cpp @@ -0,0 +1,381 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +#ifdef BOOST_CLBL_TRTS_GCC_OLDER_THAN_4_9_2 +//gcc < 4.9 doesn't like the invoke_case pattern used here +int main(){} +#else + +template +struct tag { + using type = T; +}; + +template +struct invoke_case { + template + void operator()(tag) const { + +// when available, test parity with std implementation (c++2a breaks our expectations but we still match std impl) +#if defined(__cpp_lib_is_invocable) || __cplusplus >= 201707L + CT_ASSERT((std::is_invocable() == boost::callable_traits::is_invocable())); +#else + CT_ASSERT((Expect == boost::callable_traits::is_invocable())); +#endif + + } +}; + +template +void run_tests() { + using ignored = int[]; + ignored x {(InvokeCases{}(tag{}),0)..., 0}; + (void)x; +} + +struct foo {}; + +int main() { + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + +// MSVC doesn't handle cv + ref qualifiers in expression sfinae correctly +#ifndef BOOST_CLBL_TRTS_MSVC + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + +#endif // #ifndef BOOST_CLBL_TRTS_MSVC + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + auto f = [](int){}; + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + auto g = [](){}; + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + +// libc++ requires constructible types be passed to std::is_invocable +#ifndef _LIBCPP_VERSION + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); +#endif + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); +} + +#endif //#ifdef BOOST_CLBL_TRTS_GCC_OLDER_THAN_4_9_2 diff --git a/src/boost/libs/callable_traits/test/is_invocable_r.cpp b/src/boost/libs/callable_traits/test/is_invocable_r.cpp new file mode 100644 index 000000000..f64de2ece --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_invocable_r.cpp @@ -0,0 +1,328 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +#ifdef BOOST_CLBL_TRTS_GCC_OLDER_THAN_4_9_2 +//gcc < 4.9 doesn't like the invoke_case pattern used here +int main(){} +#else + +template +struct tag { + using type = T; +}; + +template +struct invoke_case { + template + void operator()(tag) const { + +// when available, test parity with std implementation (c++2a breaks our expectations but we still match std impl) +#if defined(__cpp_lib_is_invocable) || __cplusplus >= 201707L + CT_ASSERT((std::is_invocable_r() == boost::callable_traits::is_invocable_r())); +#else + CT_ASSERT((Expect == boost::callable_traits::is_invocable_r())); +#endif + + } +}; + +template +void run_tests() { + using ignored = int[]; + ignored x {(InvokeCases{}(tag{}),0)..., 0}; + (void)x; +} + +struct foo {}; + +int main() { + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + +// MSVC doesn't handle cv + ref qualifiers in expression sfinae correctly +#ifndef BOOST_CLBL_TRTS_MSVC + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + +#endif // #ifndef BOOST_CLBL_TRTS_MSVC + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + auto f = [](int){}; + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + >(); + + auto g = [](){}; + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + >(); + +// libc++ requires constructible types be passed to std::is_invocable +#ifndef _LIBCPP_VERSION + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); +#endif + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); + + run_tests + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case> + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case + ,invoke_case, int> + >(); +} + +#endif //#ifdef BOOST_CLBL_TRTS_GCC_OLDER_THAN_4_9_2 diff --git a/src/boost/libs/callable_traits/test/is_lvalue_reference_member.cpp b/src/boost/libs/callable_traits/test/is_lvalue_reference_member.cpp new file mode 100644 index 000000000..b18e6a6fe --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_lvalue_reference_member.cpp @@ -0,0 +1,126 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +struct foo {}; + +template +void assert_lvalue_qualified() { + + CT_ASSERT( is_lvalue_reference_member()); +} + + +template +void assert_not_lvalue_qualified() { + + CT_ASSERT(! is_lvalue_reference_member()); +} + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() && ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() & { return 0; } }; + struct r { int operator()() && { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const & { return 0; } }; + struct cr { int operator()() const && { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile & { return 0; } }; + struct vr { int operator()() volatile && { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile & { return 0; } }; + struct cvr { int operator()() const volatile && { return 0; } }; + + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_lvalue_qualified(); + assert_not_lvalue_qualified(); + } + + { + using f = void(); + using l = void() &; + using r = void() && ; + using c = void() const; + using cl = void() const &; + using cr = void() const &&; + using v = void() volatile; + using vl = void() volatile &; + using vr = void() volatile &&; + using cv = void() const volatile; + using cvl = void() const volatile &; + using cvr = void() const volatile &&; + + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT( is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT( is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT( is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + CT_ASSERT( is_lvalue_reference_member()); + CT_ASSERT(! is_lvalue_reference_member()); + } + + using f_ptr = void(*)(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); + assert_not_lvalue_qualified(); +} + +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/test/is_noexcept.cpp b/src/boost/libs/callable_traits/test/is_noexcept.cpp new file mode 100644 index 000000000..e92129ee4 --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_noexcept.cpp @@ -0,0 +1,43 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include + +#include +#include "test.hpp" + +template +void test() { + + CT_ASSERT( is_noexcept::value + // for old compilers, TEST_NOEXCEPT_QUAL is empty so types are same + || std::is_same::value); + + CT_ASSERT(! is_noexcept::value); +} + +#define TEST_NOEXCEPT(not_noexcept) test() + +int main() { + + TEST_NOEXCEPT(int(*)()); + + #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + TEST_NOEXCEPT(int() const); + TEST_NOEXCEPT(int(...) volatile LREF); + #endif + + TEST_NOEXCEPT(int(*)(...)); + + struct foo; + + TEST_NOEXCEPT(int(foo::*)()); + TEST_NOEXCEPT(int(foo::*)() const volatile); + TEST_NOEXCEPT(int(foo::*)(...)); + TEST_NOEXCEPT(int(foo::*)(...) const volatile RREF); +} + diff --git a/src/boost/libs/callable_traits/test/is_rvalue_reference_member.cpp b/src/boost/libs/callable_traits/test/is_rvalue_reference_member.cpp new file mode 100644 index 000000000..6eaa2e9cc --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_rvalue_reference_member.cpp @@ -0,0 +1,126 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +struct foo {}; + +template +void assert_rvalue_qualified() { + + CT_ASSERT( is_rvalue_reference_member()); +} + + +template +void assert_not_rvalue_qualified() { + + CT_ASSERT(! is_rvalue_reference_member()); +} + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() && ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() & { return 0; } }; + struct r { int operator()() && { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const & { return 0; } }; + struct cr { int operator()() const && { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile & { return 0; } }; + struct vr { int operator()() volatile && { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile & { return 0; } }; + struct cvr { int operator()() const volatile && { return 0; } }; + + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_rvalue_qualified(); + } + + { + using f = void(); + using l = void() &; + using r = void() && ; + using c = void() const; + using cl = void() const &; + using cr = void() const &&; + using v = void() volatile; + using vl = void() volatile &; + using vr = void() volatile &&; + using cv = void() const volatile; + using cvl = void() const volatile &; + using cvr = void() const volatile &&; + + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT( is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT( is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT( is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT(! is_rvalue_reference_member()); + CT_ASSERT( is_rvalue_reference_member()); + } + + using f_ptr = void(*)(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); + assert_not_rvalue_qualified(); +} + +#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/test/is_transaction_safe.cpp b/src/boost/libs/callable_traits/test/is_transaction_safe.cpp new file mode 100644 index 000000000..e1cedd015 --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_transaction_safe.cpp @@ -0,0 +1,41 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#include "test.hpp" + +template +void test() { + + CT_ASSERT( is_transaction_safe::value + // for when tx safe is disabled + || std::is_same::value); + CT_ASSERT(! is_transaction_safe::value); +} + +#define TEST_TRANSACTION_SAFE(not_safe) \ + test() + +int main() { + + TEST_TRANSACTION_SAFE(int(*)()); + + #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + TEST_TRANSACTION_SAFE(int(...) volatile LREF); + TEST_TRANSACTION_SAFE(int() const); + #endif + + TEST_TRANSACTION_SAFE(int(*)(...)); + + struct foo; + + TEST_TRANSACTION_SAFE(int(foo::*)()); + TEST_TRANSACTION_SAFE(int(foo::*)() const volatile); + TEST_TRANSACTION_SAFE(int(foo::*)(...)); + TEST_TRANSACTION_SAFE(int(foo::*)(...) const volatile RREF); +} + diff --git a/src/boost/libs/callable_traits/test/is_volatile_member.cpp b/src/boost/libs/callable_traits/test/is_volatile_member.cpp new file mode 100644 index 000000000..26522e84c --- /dev/null +++ b/src/boost/libs/callable_traits/test/is_volatile_member.cpp @@ -0,0 +1,121 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo {}; + +template +void assert_volatile_qualified() { + CT_ASSERT( is_volatile_member::value); +} + + +template +void assert_not_volatile_qualified() { + CT_ASSERT(! is_volatile_member::value); +} + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() LREF; + using r = void(foo::*)() RREF ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const LREF; + using cr = void(foo::*)() const RREF; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile LREF; + using vr = void(foo::*)() volatile RREF; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile LREF; + using cvr = void(foo::*)() const volatile RREF; + + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + } + + { + struct f { int operator()() { return 0; } }; + struct l { int operator()() LREF { return 0; } }; + struct r { int operator()() RREF { return 0; } }; + struct c { int operator()() const { return 0; } }; + struct cl { int operator()() const LREF { return 0; } }; + struct cr { int operator()() const RREF { return 0; } }; + struct v { int operator()() volatile { return 0; } }; + struct vl { int operator()() volatile LREF { return 0; } }; + struct vr { int operator()() volatile RREF { return 0; } }; + struct cv { int operator()() const volatile { return 0; } }; + struct cvl { int operator()() const volatile LREF { return 0; } }; + struct cvr { int operator()() const volatile RREF { return 0; } }; + + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + assert_volatile_qualified(); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(! is_volatile_member()); + CT_ASSERT(! is_volatile_member()); + CT_ASSERT(! is_volatile_member()); + CT_ASSERT(! is_volatile_member()); + CT_ASSERT(! is_volatile_member()); + CT_ASSERT(! is_volatile_member()); + CT_ASSERT( is_volatile_member()); + CT_ASSERT( is_volatile_member()); + CT_ASSERT( is_volatile_member()); + CT_ASSERT( is_volatile_member()); + CT_ASSERT( is_volatile_member()); + CT_ASSERT( is_volatile_member()); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + using f_ptr = void(*)(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); + assert_not_volatile_qualified(); +} diff --git a/src/boost/libs/callable_traits/test/qualified_class_of.cpp b/src/boost/libs/callable_traits/test/qualified_class_of.cpp new file mode 100644 index 000000000..59a985102 --- /dev/null +++ b/src/boost/libs/callable_traits/test/qualified_class_of.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include "test.hpp" + +struct foo; + +int main() { + + { + using f = void(foo::*)(); + using test = TRAIT(qualified_class_of, f); + using expect = foo &; + CT_ASSERT(std::is_same::value); + } + + { + using f = void(foo::*)() const; + using test = TRAIT(qualified_class_of, f); + using expect = foo const &; + CT_ASSERT(std::is_same::value); + } + + { + using f = void(foo::*)() volatile; + using test = TRAIT(qualified_class_of, f); + using expect = foo volatile &; + CT_ASSERT(std::is_same::value); + } + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int, ...) const volatile; + using test = TRAIT(qualified_class_of, f); + using expect = foo const volatile &; + CT_ASSERT(std::is_same::value); + } + + { + using f = int foo::*; + using test = TRAIT(qualified_class_of, f); + using expect = foo const &; + CT_ASSERT(std::is_same::value); + } + + { + using f = const int foo::*; + using test = TRAIT(qualified_class_of, f); + using expect = foo const &; + CT_ASSERT(std::is_same::value); + } +} diff --git a/src/boost/libs/callable_traits/test/qualified_class_of_constraints.cpp b/src/boost/libs/callable_traits/test/qualified_class_of_constraints.cpp new file mode 100644 index 000000000..c86d51153 --- /dev/null +++ b/src/boost/libs/callable_traits/test/qualified_class_of_constraints.cpp @@ -0,0 +1,52 @@ + +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include "test.hpp" + +template +struct is_substitution_failure_qualified_class_of { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +struct foo; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); + CT_ASSERT(is_substitution_failure_qualified_class_of::value); +} + diff --git a/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.cpp b/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.cpp new file mode 100644 index 000000000..ed01eaa10 --- /dev/null +++ b/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.cpp @@ -0,0 +1,48 @@ + +#include +#include "test.hpp" + +struct foo; + +#define CALLABLE_TRAIT_UNDER_TEST add_member_const +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST remove_member_const +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST add_member_volatile +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST remove_member_volatile +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST add_member_cv +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST remove_member_cv +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS + +#define CALLABLE_TRAIT_UNDER_TEST add_member_lvalue_reference +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST add_member_rvalue_reference +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#define CALLABLE_TRAIT_UNDER_TEST remove_member_reference +#include "qualifier_metafunction_constraints.hpp" +#undef CALLABLE_TRAIT_UNDER_TEST + +#endif // #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS + +int main(){} + diff --git a/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.hpp b/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.hpp new file mode 100644 index 000000000..b3bf664cb --- /dev/null +++ b/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.hpp @@ -0,0 +1,48 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +HEADER GUARDS INTENTIONALLY OMITTED +*/ + +#ifndef PP_CAT +#define PP_CAT_(x, y) x ## y +#define PP_CAT(x, y) PP_CAT_(x, y) +#endif + +template +struct PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST) { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +bool PP_CAT(test_, CALLABLE_TRAIT_UNDER_TEST)() { + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + + auto lambda = [](){}; + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)::value); + return true; +} + +auto PP_CAT(var_, CALLABLE_TRAIT_UNDER_TEST) = PP_CAT(test_, CALLABLE_TRAIT_UNDER_TEST)(); diff --git a/src/boost/libs/callable_traits/test/remove_member_const.cpp b/src/boost/libs/callable_traits/test/remove_member_const.cpp new file mode 100644 index 000000000..1c16f29e6 --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_member_const.cpp @@ -0,0 +1,106 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + + + +struct foo {}; + +int main() { + + { + using f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) LREF; + using r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) RREF ; + using c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const LREF; + using cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const RREF; + using v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile LREF; + using vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile RREF; + using cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile LREF; + using cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = foo const & (foo::*)(int, int); + using l = foo const & (foo::*)(int, int) LREF; + using r = foo const & (foo::*)(int, int) RREF ; + using c = foo const & (foo::*)(int, int) const; + using cl = foo const & (foo::*)(int, int) const LREF; + using cr = foo const & (foo::*)(int, int) const RREF; + using v = foo const & (foo::*)(int, int) volatile; + using vl = foo const & (foo::*)(int, int) volatile LREF; + using vr = foo const & (foo::*)(int, int) volatile RREF; + using cv = foo const & (foo::*)(int, int) const volatile; + using cvl = foo const & (foo::*)(int, int) const volatile LREF; + using cvr = foo const & (foo::*)(int, int) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#endif +} diff --git a/src/boost/libs/callable_traits/test/remove_member_reference.cpp b/src/boost/libs/callable_traits/test/remove_member_reference.cpp new file mode 100644 index 000000000..67a8b6c7a --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_member_reference.cpp @@ -0,0 +1,78 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + + +struct foo{}; + +int main() { + { + using f = void(foo::*)(); + using l = void(foo::*)() &; + using r = void(foo::*)() &&; + using c = void(foo::*)() const; + using cl = void(foo::*)() const &; + using cr = void(foo::*)() const &&; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile &; + using vr = void(foo::*)() volatile &&; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile &; + using cvr = void(foo::*)() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(); + using l = void() &; + using r = void() &&; + using c = void() const; + using cl = void() const &; + using cr = void() const &&; + using v = void() volatile; + using vl = void() volatile &; + using vr = void() volatile &&; + using cv = void() const volatile; + using cvl = void() const volatile &; + using cvr = void() const volatile &&; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } +} + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS diff --git a/src/boost/libs/callable_traits/test/remove_member_volatile.cpp b/src/boost/libs/callable_traits/test/remove_member_volatile.cpp new file mode 100644 index 000000000..79dcacd19 --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_member_volatile.cpp @@ -0,0 +1,77 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo{}; + +int main() { + + { + using f = char(foo::*)(foo*, int); + using l = char(foo::*)(foo*, int) LREF; + using r = char(foo::*)(foo*, int) RREF; + using c = char(foo::*)(foo*, int) const; + using cl = char(foo::*)(foo*, int) const LREF; + using cr = char(foo::*)(foo*, int) const RREF; + using v = char(foo::*)(foo*, int) volatile; + using vl = char(foo::*)(foo*, int) volatile LREF; + using vr = char(foo::*)(foo*, int) volatile RREF; + using cv = char(foo::*)(foo*, int) const volatile; + using cvl = char(foo::*)(foo*, int) const volatile LREF; + using cvr = char(foo::*)(foo*, int) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = foo&&(); + using l = foo&&() LREF; + using r = foo&&() RREF; + using c = foo&&() const; + using cl = foo&&() const LREF; + using cr = foo&&() const RREF; + using v = foo&&() volatile; + using vl = foo&&() volatile LREF; + using vr = foo&&() volatile RREF; + using cv = foo&&() const volatile; + using cvl = foo&&() const volatile LREF; + using cvr = foo&&() const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + +} diff --git a/src/boost/libs/callable_traits/test/remove_noexcept.cpp b/src/boost/libs/callable_traits/test/remove_noexcept.cpp new file mode 100644 index 000000000..8cb8b1482 --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_noexcept.cpp @@ -0,0 +1,36 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include +#include "test.hpp" + +#include + +template +void test() { + + CT_ASSERT(std::is_same::value); +} + +#define TEST_NOEXCEPT(not_noexcept) \ + test() + +int main() { + + TEST_NOEXCEPT(int(int) LREF); + TEST_NOEXCEPT(int(*)(int)); + TEST_NOEXCEPT(int(int, ...) RREF); + TEST_NOEXCEPT(int(*)(int, ...)); + + struct foo; + + TEST_NOEXCEPT(int(foo::*)(int)); + TEST_NOEXCEPT(int(foo::*)(int) const); + TEST_NOEXCEPT(int(foo::*)(int, ...)); + TEST_NOEXCEPT(int(foo::*)(int, ...) volatile); +} + diff --git a/src/boost/libs/callable_traits/test/remove_noexcept_constraints.cpp b/src/boost/libs/callable_traits/test/remove_noexcept_constraints.cpp new file mode 100644 index 000000000..9df96a42e --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_noexcept_constraints.cpp @@ -0,0 +1,51 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +template +struct is_substitution_failure_remove_noexcept { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +struct foo; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); + CT_ASSERT(is_substitution_failure_remove_noexcept::value); +} + +#endif //#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE diff --git a/src/boost/libs/callable_traits/test/remove_transaction_safe.cpp b/src/boost/libs/callable_traits/test/remove_transaction_safe.cpp new file mode 100644 index 000000000..481041545 --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_transaction_safe.cpp @@ -0,0 +1,39 @@ +/*<- +Copyright (c) 2016 Barrett Adair + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +->*/ + +#include "test.hpp" +#include + +template +void test() { + + CT_ASSERT(std::is_same::value); + + //sanity check + #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + CT_ASSERT(!std::is_same::value); + #endif +} + +#define TEST_TRANSACTION_SAFE(not_safe) \ + test() + +int main() { + + TEST_TRANSACTION_SAFE(int(int) LREF); + TEST_TRANSACTION_SAFE(int(*)(int)); + TEST_TRANSACTION_SAFE(int(int, ...) RREF); + TEST_TRANSACTION_SAFE(int(*)(int, ...)); + + struct foo; + + TEST_TRANSACTION_SAFE(int(foo::*)(int)); + TEST_TRANSACTION_SAFE(int(foo::*)(int) const); + TEST_TRANSACTION_SAFE(int(foo::*)(int, ...)); + TEST_TRANSACTION_SAFE(int(foo::*)(int, ...) volatile); +} + diff --git a/src/boost/libs/callable_traits/test/remove_transaction_safe_constraints.cpp b/src/boost/libs/callable_traits/test/remove_transaction_safe_constraints.cpp new file mode 100644 index 000000000..0daadebed --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_transaction_safe_constraints.cpp @@ -0,0 +1,51 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +template +struct is_substitution_failure_remove_tx_safe { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +struct foo; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe::value); +} + +#endif //#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE diff --git a/src/boost/libs/callable_traits/test/remove_varargs.cpp b/src/boost/libs/callable_traits/test/remove_varargs.cpp new file mode 100644 index 000000000..f5f91d6fc --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_varargs.cpp @@ -0,0 +1,190 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include "test.hpp" + + + +struct foo {}; + +int main() { + + { + using f = void(foo::*)(); + using l = void(foo::*)() LREF; + using r = void(foo::*)() RREF ; + using c = void(foo::*)() const; + using cl = void(foo::*)() const LREF; + using cr = void(foo::*)() const RREF; + using v = void(foo::*)() volatile; + using vl = void(foo::*)() volatile LREF; + using vr = void(foo::*)() volatile RREF; + using cv = void(foo::*)() const volatile; + using cvl = void(foo::*)() const volatile LREF; + using cvr = void(foo::*)() const volatile RREF; + + using va_f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...); + using va_l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) LREF; + using va_r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) RREF ; + using va_c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const; + using va_cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const LREF; + using va_cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const RREF; + using va_v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile; + using va_vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile LREF; + using va_vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile RREF; + using va_cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile; + using va_cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile LREF; + using va_cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + + { + using f = void(foo::*)(int&, int&&); + using l = void(foo::*)(int&, int&&) LREF; + using r = void(foo::*)(int&, int&&) RREF ; + using c = void(foo::*)(int&, int&&) const; + using cl = void(foo::*)(int&, int&&) const LREF; + using cr = void(foo::*)(int&, int&&) const RREF; + using v = void(foo::*)(int&, int&&) volatile; + using vl = void(foo::*)(int&, int&&) volatile LREF; + using vr = void(foo::*)(int&, int&&) volatile RREF; + using cv = void(foo::*)(int&, int&&) const volatile; + using cvl = void(foo::*)(int&, int&&) const volatile LREF; + using cvr = void(foo::*)(int&, int&&) const volatile RREF; + + using va_f = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...); + using va_l = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) LREF; + using va_r = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) RREF ; + using va_c = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const; + using va_cl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const LREF; + using va_cr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const RREF; + using va_v = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) volatile; + using va_vl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) volatile LREF; + using va_vr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) volatile RREF; + using va_cv = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const volatile; + using va_cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const volatile LREF; + using va_cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int&, int&&, ...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(); + using l = void() LREF; + using r = void() RREF ; + using c = void() const; + using cl = void() const LREF; + using cr = void() const RREF; + using v = void() volatile; + using vl = void() volatile LREF; + using vr = void() volatile RREF; + using cv = void() const volatile; + using cvl = void() const volatile LREF; + using cvr = void() const volatile RREF; + + using va_f = void(...); + using va_l = void(...) LREF; + using va_r = void(...) RREF ; + using va_c = void(...) const; + using va_cl = void(...) const LREF; + using va_cr = void(...) const RREF; + using va_v = void(...) volatile; + using va_vl = void(...) volatile LREF; + using va_vr = void(...) volatile RREF; + using va_cv = void(...) const volatile; + using va_cvl = void(...) const volatile LREF; + using va_cvr = void(...) const volatile RREF; + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + CT_ASSERT(std::is_same{}); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(&)(); + using va_f = void(&)(...); + CT_ASSERT(std::is_same{}); + } +} diff --git a/src/boost/libs/callable_traits/test/remove_varargs_constraints.hpp b/src/boost/libs/callable_traits/test/remove_varargs_constraints.hpp new file mode 100644 index 000000000..d891fba5e --- /dev/null +++ b/src/boost/libs/callable_traits/test/remove_varargs_constraints.hpp @@ -0,0 +1,45 @@ +/* +Copyright Barrett Adair 2016-2017 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include "test.hpp" + +struct foo; + +template +struct is_substitution_failure_remove_varargs { + + template + static auto test(...) -> std::true_type; + + template::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); + CT_ASSERT(is_substitution_failure_remove_varargs::value); +} diff --git a/src/boost/libs/callable_traits/test/return_type.cpp b/src/boost/libs/callable_traits/test/return_type.cpp new file mode 100644 index 000000000..11362c073 --- /dev/null +++ b/src/boost/libs/callable_traits/test/return_type.cpp @@ -0,0 +1,56 @@ +/* + +Copyright Barrett Adair 2015-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#include +#include +#include +#include +#include "test.hpp" + +struct foo1 { + int bar(char, float&, int = 0) { return{}; } +}; + +struct foo2 { + int bar(char, float&, int = 0, ...) { return{}; } +}; + +struct foo3 { + int operator()(char, float&, int = 0) { return{}; } +}; + +struct foo4 { + int operator()(char, float&, int = 0, ...) { return{}; } +}; + +int foo5(char, float&, int = 0) { return{}; } + +int foo6(char, float&, int = 0, ...) { return{}; } + +using std::is_same; + +int main() { + + { + using pmf = decltype(&foo1::bar); + CT_ASSERT(std::is_same< return_type_t, int>{}); + } { + using pmf = decltype(&foo2::bar); + CT_ASSERT(std::is_same< return_type_t, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t, int>{}); + } + + return 0; +} diff --git a/src/boost/libs/callable_traits/test/test.hpp b/src/boost/libs/callable_traits/test/test.hpp new file mode 100644 index 000000000..58266c954 --- /dev/null +++ b/src/boost/libs/callable_traits/test/test.hpp @@ -0,0 +1,56 @@ +/* +Copyright Barrett Adair 2016-2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) +*/ + +#include +#include +#include +#include +#include + +using namespace boost::callable_traits; + +#ifndef CT_ASSERT +#define CT_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) +#endif //CT_ASSERT + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +#define LREF +#define RREF +#else +#define LREF & +#define RREF && +#endif + +#define TX_SAFE BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER +#define VA_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC + +#ifndef PP_CAT +#define PP_CAT_(x, y) x ## y +#define PP_CAT(x, y) PP_CAT_(x, y) +#endif + +#ifdef USE_LAZY_TYPES +#define TRAIT(trait, ...) typename trait<__VA_ARGS__>::type +#else +#define TRAIT(trait, ...) PP_CAT(trait, _t)<__VA_ARGS__> +#endif + +#ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +#define TEST_NOEXCEPT_QUAL noexcept +#else +#define TEST_NOEXCEPT_QUAL +#endif + +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +#define TEST_ABOM_V +#else +#define TEST_ABOM_V volatile +#endif + +template +void assert_same() { + CT_ASSERT(std::is_same::value); +} -- cgit v1.2.3