diff options
Diffstat (limited to 'src/boost/libs/callable_traits')
97 files changed, 6485 insertions, 0 deletions
diff --git a/src/boost/libs/callable_traits/CMakeLists.txt b/src/boost/libs/callable_traits/CMakeLists.txt new file mode 100644 index 00000000..c45552eb --- /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 + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" + $<INSTALL_INTERFACE:include>) + +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(<output variable> <source file> [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(<name> <command> [<arg>...]) +# 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 00000000..901f174c --- /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 00000000..935520d2 --- /dev/null +++ b/src/boost/libs/callable_traits/README.md @@ -0,0 +1,19 @@ +<!-- +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) +--> + +# Boost.CallableTraits <a target="_blank" href="https://travis-ci.org/boostorg/callable_traits">![Travis status][badge.Travis]</a> <a target="_blank" href="https://ci.appveyor.com/project/boostorg/callable-traits">![Appveyor status][badge.Appveyor]</a> + +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). + +<!-- Links --> +[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 00000000..5a6108d2 --- /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 00000000..d94b84f6 --- /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 + <toolset>clang:<cxxflags>"-pedantic -Wall -Wextra" + <toolset>darwin:<cxxflags>"-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 00000000..83dba2a9 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_const +#include <type_traits> +#include <boost/callable_traits/add_member_const.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() volatile &; + using expect = int(foo::*)() const volatile &; + using test = ct::add_member_const_t<pmf>; + static_assert(std::is_same<test, expect>::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<f>; + static_assert(std::is_same<test, expect>::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 00000000..77997688 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_cv +#include <type_traits> +#include <boost/callable_traits/add_member_cv.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = void(foo::*)() volatile &; + using expect = void(foo::*)() const volatile &; + using test = ct::add_member_cv_t<pmf>; + static_assert(std::is_same<test, expect>::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<f>; + static_assert(std::is_same<test, expect>::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 00000000..8d168a29 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_lvalue_reference +#include <type_traits> +#include <boost/callable_traits/add_member_lvalue_reference.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::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<f>; + static_assert(std::is_same<test, expect>::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 00000000..81ecf257 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_rvalue_reference +#include <type_traits> +#include <boost/callable_traits/add_member_rvalue_reference.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::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<f>; + static_assert(std::is_same<test, expect>::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 00000000..ffddcbfe --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ add_member_volatile +#include <type_traits> +#include <boost/callable_traits/add_member_volatile.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::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<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = void(foo::*)() const &; + using expect = void(foo::*)() const volatile &; + using test = ct::add_member_volatile_t<pmf>; + static_assert(std::is_same<test, expect>::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<f>; + static_assert(std::is_same<test, expect>::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 00000000..fa5ff906 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +//[ add_noexcept +#include <type_traits> +#include <boost/callable_traits/add_noexcept.hpp> + +using boost::callable_traits::add_noexcept_t; + +static_assert(std::is_same< + add_noexcept_t<int()>, + 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 00000000..92a6ea71 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +//[ add_transaction_safe +#include <type_traits> +#include <boost/callable_traits/add_transaction_safe.hpp> + +using boost::callable_traits::add_transaction_safe_t; + +using not_safe = int(); +using safe = int() transaction_safe; +using safe_added = add_transaction_safe_t<not_safe>; + +static_assert(std::is_same<safe, safe_added>{}, ""); + +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 00000000..8538c00b --- /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 <type_traits> +#include <boost/callable_traits/add_varargs.hpp> + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using f = void(int); + using expect = void(int, ...); + using test = ct::add_varargs_t<f>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using fp = void(*)(); + using expect = void(*)(...); + using test = ct::add_varargs_t<fp>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using fr = void(&)(const char*); + using expect = void(&)(const char*, ...); + using test = ct::add_varargs_t<fr>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = void(foo::*)() const; + using expect = void(foo::*)(...) const; + using test = ct::add_varargs_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + + // add_varargs_t doesn't change anything when + // the type already has varargs. + using twice = ct::add_varargs_t<test>; + static_assert(std::is_same<test, twice>::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 00000000..63a944d3 --- /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 <type_traits> +#include <boost/callable_traits/apply_member_pointer.hpp> + +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<f, foo>; + using expect = int(foo::*)(int); + static_assert(std::is_same<g, expect>::value, ""); + } + + { + // function pointer type (unqualified) -> member function pointer type + using f = int(*)(); + using g = ct::apply_member_pointer_t<f, foo>; + using expect = int(foo::*)(); + static_assert(std::is_same<g, expect>::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<f, foo>; + using expect = int (* foo::*)(); + static_assert(std::is_same<g, expect>::value, ""); + } + + { + using f = int(* const)(); + using g = ct::apply_member_pointer_t<f, foo>; + using expect = int (* const foo::*)(); + static_assert(std::is_same<g, expect>::value, ""); + } + } + + { + // function reference type -> member function pointer type + using f = void(&)(); + using g = ct::apply_member_pointer_t<f, foo>; + using expect = void(foo::*)(); + static_assert(std::is_same<g, expect>::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<f, foo>; + using expect = int(foo::*)() const; + static_assert(std::is_same<g, expect>::value, ""); + } + + { + // non-callable type -> member data pointer type + using g = ct::apply_member_pointer_t<int, foo>; + using expect = int foo::*; + static_assert(std::is_same<g, expect>::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<f, foo>; + using expect = f foo::*; + static_assert(std::is_same<g, expect>::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 00000000..9e0ef2d9 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ args +#include <type_traits> +#include <memory> +#include <boost/callable_traits.hpp> + +namespace ct = boost::callable_traits; + +template<typename T, typename Expect> +void test(){ + using args_t = ct::args_t<T>; + static_assert(std::is_same<args_t, Expect>::value, ""); +} + +int main() { + + { + auto lamda = [](int, float&, const char*){}; + using lam = decltype(lamda); + using expect = std::tuple<int, float&, const char*>; + + test<lam, expect>(); + } + + { + struct foo; + using pmf = void(foo::*)(int, float&, const char*); + using expect = std::tuple<foo&, int, float&, const char*>; + + test<pmf, expect>(); + } + + { + using function_ptr = void(*)(int, float&, const char*); + using expect = std::tuple<int, float&, const char*>; + test<function_ptr, expect>(); + } + + { + using function_ref = void(&)(int, float&, const char*); + using expect = std::tuple<int, float&, const char*>; + test<function_ref, expect>(); + } + + { + using function = void(int, float&, const char*); + using expect = std::tuple<int, float&, const char*>; + test<function, expect>(); + } + + { + using abominable = void(int, float&, const char*) const; + using expect = std::tuple<int, float&, const char*>; + test<abominable, expect>(); + } +} +//] +#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 00000000..9a75977e --- /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 <boost/callable_traits/detail/config.hpp> + +//[ class_of +#include <type_traits> +#include <boost/callable_traits/class_of.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(std::is_same<foo, ct::class_of_t<int(foo::*)()>>::value, ""); +static_assert(std::is_same<foo, ct::class_of_t<int foo::*>>::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 00000000..8047bbb8 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ function_type +#include <type_traits> +#include <boost/callable_traits.hpp> + +namespace ct = boost::callable_traits; + +template<typename T> +void test(){ + + // this example shows how boost::callable_traits::function_type_t + // bevaves consistently for many different types + using type = ct::function_type_t<T>; + using expect = void(int, float&, const char*); + static_assert(std::is_same<expect, type>{}, ""); +} + +int main() { + + auto lamda = [](int, float&, const char*){}; + using lam = decltype(lamda); + test<lam>(); + + using function_ptr = void(*)(int, float&, const char*); + test<function_ptr>(); + + using function_ref = void(&)(int, float&, const char*); + test<function_ref>(); + + using function = void(int, float&, const char*); + test<function>(); + + using abominable = void(int, float&, const char*) const; + test<abominable>(); +} +//] +#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 00000000..2f37f092 --- /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 <type_traits> +#include <boost/callable_traits/remove_member_const.hpp> + +struct foo { + void bar() const {} +}; + +using const_removed = boost::callable_traits::remove_member_const_t<decltype(&foo::bar)>; + +static_assert(std::is_same<const_removed, void(foo::*)()>::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 00000000..79378c3a --- /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 <type_traits> +#include <boost/callable_traits/has_member_qualifiers.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::has_member_qualifiers<int(foo::*)() const>::value, ""); +static_assert(ct::has_member_qualifiers<int(foo::*)() volatile>::value, ""); +static_assert(!ct::has_member_qualifiers<int(foo::*)()>::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 00000000..1dd66fd4 --- /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 <type_traits> +#include <boost/callable_traits/has_varargs.hpp> + +namespace ct = boost::callable_traits; + +static_assert(ct::has_varargs<int(...)>::value, ""); +static_assert(!ct::has_varargs<int()>::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 00000000..3e14561a --- /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 <type_traits> +#include <boost/callable_traits/has_void_return.hpp> + +namespace ct = boost::callable_traits; + +static_assert(ct::has_void_return<void()>::value, ""); +static_assert(!ct::has_void_return<int()>::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 00000000..a1e05096 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES +int main(){ return 0; } +#else + +//[ intro +#include <type_traits> +#include <tuple> +#include <boost/callable_traits.hpp> + +namespace ct = boost::callable_traits; + +// This function template helps keep our example code neat +template<typename A, typename B> +void assert_same(){ static_assert(std::is_same<A, B>::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<foo>, + std::tuple<int, char, float> + >(); + + // has_void_return lets us perform a quick check for a void return type + static_assert(ct::has_void_return<foo>::value, ""); + + // Detect C-style variadics (ellipses) in a signature (e.g. printf) + static_assert(!ct::has_varargs<foo>::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<pmf>, + 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<void (foo::*)(int, char, float)> + >(); + + // is_const_member_v checks for the presence of member const + static_assert(ct::is_const_member<pmf>::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 00000000..110e7630 --- /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 <type_traits> +#include <boost/callable_traits/is_const_member.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_const_member<int(foo::*)() const>::value, ""); +static_assert(!ct::is_const_member<int(foo::*)()>::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 00000000..638c219e --- /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 <type_traits> +#include <boost/callable_traits/is_cv_member.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_cv_member<int(foo::*)() const volatile>::value, ""); +static_assert(!ct::is_cv_member<int(foo::*)()>::value, ""); +static_assert(!ct::is_cv_member<int(foo::*)() const>::value, ""); +static_assert(!ct::is_cv_member<int(foo::*)() volatile>::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 00000000..a374de01 --- /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 <type_traits> +#include <boost/callable_traits/is_invocable.hpp> + +namespace ct = boost::callable_traits; + +struct foo { + template<typename T> + typename std::enable_if<std::is_integral<T>::value>::type + operator()(T){} +}; + +static_assert(ct::is_invocable<foo, int>::value, ""); +static_assert(!ct::is_invocable<foo, double>::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 00000000..4cc96e85 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ is_lvalue_reference_member +#include <type_traits> +#include <boost/callable_traits/is_lvalue_reference_member.hpp> + +namespace ct = boost::callable_traits; + +static_assert(ct::is_lvalue_reference_member<int()&>::value, ""); +static_assert(!ct::is_lvalue_reference_member<int()&&>::value, ""); +static_assert(!ct::is_lvalue_reference_member<int()>::value, ""); + +struct foo; + +static_assert(ct::is_lvalue_reference_member<int(foo::*)()&>::value, ""); +static_assert(!ct::is_lvalue_reference_member<int(foo::*)()&&>::value, ""); +static_assert(!ct::is_lvalue_reference_member<int(foo::*)()>::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 00000000..0c4e8388 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +//[ is_noexcept +#include <boost/callable_traits/is_noexcept.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_noexcept<int() noexcept>::value, ""); +static_assert(ct::is_noexcept<int(*)() noexcept>::value, ""); +static_assert(ct::is_noexcept<int(&)() noexcept>::value, ""); +static_assert(ct::is_noexcept<int(foo::*)() const noexcept>::value, ""); + +static_assert(!ct::is_noexcept<int()>::value, ""); +static_assert(!ct::is_noexcept<int(*)()>::value, ""); +static_assert(!ct::is_noexcept<int(&)()>::value, ""); +static_assert(!ct::is_noexcept<int(foo::*)() const>::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 00000000..480fb558 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ is_reference_member +#include <type_traits> +#include <boost/callable_traits/is_reference_member.hpp> + +namespace ct = boost::callable_traits; + +static_assert(ct::is_reference_member<int()&>::value, ""); +static_assert(ct::is_reference_member<int()&&>::value, ""); +static_assert(!ct::is_reference_member<int()>::value, ""); + +struct foo; + +static_assert(ct::is_reference_member<int(foo::*)()&>::value, ""); +static_assert(ct::is_reference_member<int(foo::*)()&&>::value, ""); +static_assert(!ct::is_reference_member<int(foo::*)()>::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 00000000..162c1237 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ is_rvalue_reference_member +#include <type_traits> +#include <boost/callable_traits/is_rvalue_reference_member.hpp> + +namespace ct = boost::callable_traits; + +static_assert(ct::is_rvalue_reference_member<int()&&>::value, ""); +static_assert(!ct::is_rvalue_reference_member<int()&>::value, ""); +static_assert(!ct::is_rvalue_reference_member<int()>::value, ""); + +struct foo; + +static_assert(ct::is_rvalue_reference_member<int(foo::*)()&&>::value, ""); +static_assert(!ct::is_rvalue_reference_member<int(foo::*)()&>::value, ""); +static_assert(!ct::is_rvalue_reference_member<int(foo::*)()>::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 00000000..26ae8d9b --- /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 <boost/callable_traits/detail/config.hpp> + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +//[ is_transaction_safe +#include <boost/callable_traits/is_transaction_safe.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(ct::is_transaction_safe<int() transaction_safe>::value, ""); +static_assert(ct::is_transaction_safe<int(*)() transaction_safe>::value, ""); +static_assert(ct::is_transaction_safe<int(&)() transaction_safe>::value, ""); +static_assert(ct::is_transaction_safe<int(foo::*)() const transaction_safe>::value, ""); + +static_assert(!ct::is_transaction_safe<int()>::value, ""); +static_assert(!ct::is_transaction_safe<int(*)()>::value, ""); +static_assert(!ct::is_transaction_safe<int(&)()>::value, ""); +static_assert(!ct::is_transaction_safe<int(foo::*)() const>::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 00000000..91dd3993 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ is_volatile_member +#include <type_traits> +#include <boost/callable_traits/is_volatile_member.hpp> + +namespace ct = boost::callable_traits; + +static_assert(ct::is_volatile_member<int() volatile>::value, ""); +static_assert(ct::is_volatile_member<int() const volatile>::value, ""); +static_assert(!ct::is_volatile_member<int()>::value, ""); + +struct foo; + +static_assert(ct::is_volatile_member<int(foo::*)() volatile>::value, ""); +static_assert(!ct::is_volatile_member<int(foo::*)() const>::value, ""); +static_assert(!ct::is_volatile_member<int(foo::*)()>::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 00000000..a5186bf9 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){} +#else + +//[ overview +#include <boost/callable_traits.hpp> + +#include <type_traits> +#include <tuple> + +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<pmf>, + int(number::*)(int) +>{}, ""); + +static_assert(is_same< + add_member_volatile_t<pmf>, + int(number::*)(int) const volatile +>{}, ""); + +static_assert(is_same< + class_of_t<pmf>, + number +>{}, ""); + +//` INVOKE-aware metafunctions: + +static_assert(is_same< + args_t<pmf>, + tuple<const number&, int> +>{}, ""); + +static_assert(is_same< + return_type_t<pmf>, + int +>{}, ""); + +static_assert(is_same< + function_type_t<pmf>, + int(const number&, int) +>{}, ""); + +static_assert(is_same< + qualified_class_of_t<pmf>, + const number& +>{}, ""); + +//` Here are a few other trait examples: +static_assert(is_const_member<pmf>{}, ""); +static_assert(!is_volatile_member<pmf>{}, ""); +static_assert(!has_void_return<pmf>{}, ""); +static_assert(!has_varargs<pmf>{}, ""); + +//] + +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 00000000..049f87e4 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ qualified_class_of +#include <type_traits> +#include <boost/callable_traits/qualified_class_of.hpp> + +namespace ct = boost::callable_traits; + +struct foo; + +static_assert(std::is_same<foo &, + ct::qualified_class_of_t<int(foo::*)()>>::value, ""); + +static_assert(std::is_same<foo const &, + ct::qualified_class_of_t<int(foo::*)() const>>::value, ""); + +static_assert(std::is_same<foo volatile &&, + ct::qualified_class_of_t<int(foo::*)() volatile &&>>::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 00000000..c0a97a5c --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_const +#include <type_traits> +#include <boost/callable_traits/remove_member_const.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() &&; + using test = ct::remove_member_const_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() const volatile &; + using expect = int(foo::*)() volatile &; + using test = ct::remove_member_const_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using f = int() const; + using expect = int(); + using test = ct::remove_member_const_t<f>; + static_assert(std::is_same<test, expect>::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 00000000..3d741fcc --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_cv +#include <type_traits> +#include <boost/callable_traits/remove_member_cv.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() &&; + using test = ct::remove_member_cv_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() const volatile &; + using expect = int(foo::*)() &; + using test = ct::remove_member_cv_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using f = int() const volatile; + using expect = int(); + using test = ct::remove_member_cv_t<f>; + static_assert(std::is_same<test, expect>::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 00000000..b08a8c6a --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_reference +#include <type_traits> +#include <boost/callable_traits/remove_member_reference.hpp> + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using pmf = int(foo::*)() &; + using expect = int(foo::*)(); + using test = ct::remove_member_reference_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() const &&; + using expect = int(foo::*)() const; + using test = ct::remove_member_reference_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() const volatile &; + using expect = int(foo::*)() const volatile; + using test = ct::remove_member_reference_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using f = int() &&; + using expect = int(); + using test = ct::remove_member_reference_t<f>; + static_assert(std::is_same<test, expect>::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 00000000..2d3fa388 --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +//[ remove_member_volatile +#include <type_traits> +#include <boost/callable_traits/remove_member_volatile.hpp> + +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<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() volatile &&; + using expect = int(foo::*)() &&; + using test = ct::remove_member_volatile_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = int(foo::*)() volatile &; + using expect = int(foo::*)() &; + using test = ct::remove_member_volatile_t<pmf>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using f = int() const volatile; + using expect = int() const; + using test = ct::remove_member_volatile_t<f>; + static_assert(std::is_same<test, expect>::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 00000000..d3b11c5e --- /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 <boost/callable_traits/detail/config.hpp> + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +//[ remove_noexcept +#include <type_traits> +#include <boost/callable_traits/remove_noexcept.hpp> + +using boost::callable_traits::remove_noexcept_t; + +static_assert(std::is_same< + remove_noexcept_t<int() noexcept>, + 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 00000000..bdf4f134 --- /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 <boost/callable_traits/detail/config.hpp> + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +//[ remove_transaction_safe +#include <type_traits> +#include <boost/callable_traits/remove_transaction_safe.hpp> + +namespace ct = boost::callable_traits; + +using ts = int() transaction_safe; +using not_ts = int(); +using ts_removed = ct::remove_transaction_safe_t<ts>; + +static_assert(std::is_same<not_ts, ts_removed>{}, ""); + +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 00000000..47194e08 --- /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 <type_traits> +#include <boost/callable_traits/remove_varargs.hpp> + +namespace ct = boost::callable_traits; + +struct foo {}; + +int main() { + + { + using f = void(int, ...); + using expect = void(int); + using test = ct::remove_varargs_t<f>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using fp = void(*)(...); + using expect = void(*)(); + using test = ct::remove_varargs_t<fp>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using fr = void(&)(const char*, ...); + using expect = void(&)(const char*); + using test = ct::remove_varargs_t<fr>; + static_assert(std::is_same<test, expect>::value, ""); + } { + using pmf = void(foo::*)(...) const; + using expect = void(foo::*)() const; + using test = ct::remove_varargs_t<pmf>; + static_assert(std::is_same<test, expect>::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 00000000..bc3a5cef --- /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 <boost/callable_traits/detail/config.hpp> +#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS +int main(){ return 0; } +#else + +//[ return_type +#include <type_traits> +#include <boost/callable_traits.hpp> + +namespace ct = boost::callable_traits; + +using expect = int; + +struct foo; + +template<typename T> +void test() { + using result = ct::return_type_t<T>; + static_assert(std::is_same<expect, result>{}, ""); +} + +int main() { + + test<int()>(); + test<int(*)()>(); + test<int(&)()>(); + test<int() const>(); + test<int(foo::*)() const>(); + + auto x = []() -> int { return 0; }; + + test<decltype(x)>(); +} +//] +#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 00000000..75fc8eee --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits.hpp> + +struct foo { + void operator()() const {} +}; + +namespace ct = boost::callable_traits; + +int main() { + + using args = ct::args_t<foo>; + using expected_args = std::tuple<>; + static_assert(std::is_same<args, expected_args>{}, ""); + + using signature = ct::function_type_t<foo>; + using expected_signature = void(); + static_assert(std::is_same<signature, expected_signature>{}, ""); + + 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 00000000..1be11653 --- /dev/null +++ b/src/boost/libs/callable_traits/index.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="refresh" content="0; URL=doc/html/index.html"> + </head> + + <body> + Automatic redirection failed, click this <a href="doc/html/index.html">link</a> + <hr> + <p>Copyright Louis Dionne, 2013-2016</p> + <p>Copyright Modified Work Barrett Adair, 2013-2016</p> + <p> + Distributed under the Boost Software License, Version 1.0. + (See accompanying file <a href="LICENSE.md">LICENSE.md</a> or copy at + <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>) + </p> + </body> +</html> 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 00000000..74423d39 --- /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 <barrettellisadair -at- gmail.com>" ], + "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 00000000..00af8eba --- /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 00000000..640a787c --- /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(<name> ...) +# +# 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 00000000..bce5f231 --- /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 ] + <toolset>clang:<cxxflags>"-pedantic -Wall -Wextra" + <toolset>darwin:<cxxflags>"-pedantic -Wall -Wextra" +; + +for local source in [ glob *.cpp ] +{ + run $(source) ; + run $(source) : : : <define>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 00000000..5a5faed3 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/add_member_const.hpp> +#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<c, TRAIT(add_member_const, f)>{}); + CT_ASSERT(std::is_same<c, TRAIT(add_member_const, c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_const, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_const, cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_const, r)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_const, cr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_const, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_const, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_const, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_const, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_const, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_const, cvr)>{}); + } + + { + 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<c, TRAIT(add_member_const, f)>{}); + CT_ASSERT(std::is_same<c, TRAIT(add_member_const, c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_const, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_const, cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_const, r)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_const, cr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_const, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_const, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_const, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_const, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_const, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_const, cvr)>{}); + } + +#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<c, TRAIT(add_member_const, f)>{}); + CT_ASSERT(std::is_same<c, TRAIT(add_member_const, c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_const, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_const, cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_const, r)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_const, cr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_const, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_const, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_const, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_const, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_const, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_const, cvr)>{}); + } +#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 00000000..cb4e04f5 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/add_member_cv.hpp> +#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<cv, TRAIT(add_member_cv, f)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, c)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, l)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, cl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, r)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, cr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, cvr)>{}); + } + + { + 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<cv, TRAIT(add_member_cv, f)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, c)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, l)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, cl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, r)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, cr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, cvr)>{}); + } + +#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<cv, TRAIT(add_member_cv, f)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, c)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, l)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, cl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, r)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, cr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_cv, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_cv, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_cv, cvr)>{}); + } + +#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 00000000..b3207542 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/add_member_lvalue_reference.hpp> +#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<l, TRAIT(add_member_lvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_lvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cvl)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_lvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<cr, TRAIT(add_member_lvalue_reference, cr)>{}); + CT_ASSERT(!std::is_same<vr, TRAIT(add_member_lvalue_reference, vr)>{}); + CT_ASSERT(!std::is_same<cvr, TRAIT(add_member_lvalue_reference, cvr)>{}); + } + + { + 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<l, TRAIT(add_member_lvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_lvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cvl)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_lvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<cr, TRAIT(add_member_lvalue_reference, cr)>{}); + CT_ASSERT(!std::is_same<vr, TRAIT(add_member_lvalue_reference, vr)>{}); + CT_ASSERT(!std::is_same<cvr, TRAIT(add_member_lvalue_reference, cvr)>{}); + } + + { + 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<l, TRAIT(add_member_lvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_lvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cvl)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_lvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<cr, TRAIT(add_member_lvalue_reference, cr)>{}); + CT_ASSERT(!std::is_same<vr, TRAIT(add_member_lvalue_reference, vr)>{}); + CT_ASSERT(!std::is_same<cvr, TRAIT(add_member_lvalue_reference, cvr)>{}); + } + + #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<l, TRAIT(add_member_lvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_lvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cvl)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_lvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<cr, TRAIT(add_member_lvalue_reference, cr)>{}); + CT_ASSERT(!std::is_same<vr, TRAIT(add_member_lvalue_reference, vr)>{}); + CT_ASSERT(!std::is_same<cvr, TRAIT(add_member_lvalue_reference, cvr)>{}); + + } + #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<l, TRAIT(add_member_lvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_lvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cvl)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_lvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<cr, TRAIT(add_member_lvalue_reference, cr)>{}); + CT_ASSERT(!std::is_same<vr, TRAIT(add_member_lvalue_reference, vr)>{}); + CT_ASSERT(!std::is_same<cvr, TRAIT(add_member_lvalue_reference, cvr)>{}); + } + #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<l, TRAIT(add_member_lvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_lvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_lvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_lvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_lvalue_reference, cvl)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_lvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<cr, TRAIT(add_member_lvalue_reference, cr)>{}); + CT_ASSERT(!std::is_same<vr, TRAIT(add_member_lvalue_reference, vr)>{}); + CT_ASSERT(!std::is_same<cvr, TRAIT(add_member_lvalue_reference, cvr)>{}); + } + #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 00000000..e7d3e870 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits.hpp> +#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<r, TRAIT(add_member_rvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_rvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_rvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_rvalue_reference, cvl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(add_member_rvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, cr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cvr)>{}); + } + + { + 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<r, TRAIT(add_member_rvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_rvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_rvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_rvalue_reference, cvl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(add_member_rvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, cr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cvr)>{}); + } + + { + 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<r, TRAIT(add_member_rvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_rvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_rvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_rvalue_reference, cvl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(add_member_rvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, cr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cvr)>{}); + } + + { + 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<r, TRAIT(add_member_rvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_rvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_rvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_rvalue_reference, cvl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(add_member_rvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, cr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cvr)>{}); + } + + { + 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<r, TRAIT(add_member_rvalue_reference, f)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, c)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, v)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cv)>{}); + CT_ASSERT(std::is_same<l, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(add_member_rvalue_reference, cl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_rvalue_reference, vl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_rvalue_reference, cvl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(add_member_rvalue_reference, r)>{}); + CT_ASSERT(!std::is_same<r, TRAIT(add_member_rvalue_reference, l)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(add_member_rvalue_reference, cr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_rvalue_reference, vr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_rvalue_reference, cvr)>{}); + } +} + +#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 00000000..a76e02e6 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/add_member_volatile.hpp> +#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<v, TRAIT(add_member_volatile, f)>{}); + CT_ASSERT(std::is_same<v, TRAIT(add_member_volatile, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, l)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, r)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, c)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cvr)>{}); + } + +#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<v, TRAIT(add_member_volatile, f)>{}); + CT_ASSERT(std::is_same<v, TRAIT(add_member_volatile, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, l)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, r)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, c)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cl)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cr)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cvr)>{}); + } + +#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 00000000..c13251a6 --- /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 <boost/callable_traits/detail/config.hpp> + + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +#include <boost/callable_traits/add_noexcept.hpp> +#include "test.hpp" + +template<typename Noexcept, typename NotNoexcept> +void test() { + + CT_ASSERT(std::is_same<Noexcept, TRAIT(add_noexcept, NotNoexcept)>::value); + + //sanity check + CT_ASSERT(!std::is_same<Noexcept, NotNoexcept>::value); +} + +#define TEST_NOEXCEPT(not_noexcept) test<not_noexcept noexcept, not_noexcept>() + +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 00000000..e6f59cb5 --- /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 <boost/callable_traits/add_noexcept.hpp> +#include <tuple> +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +struct foo; + +template<typename T> +struct is_substitution_failure_add_noexcept { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(add_noexcept, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_add_noexcept<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int &>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int (* const &)()>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int (foo::* &)()>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int (foo::* const)()>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int (foo::* const &)()>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<void>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<void*>::value); + CT_ASSERT(is_substitution_failure_add_noexcept<void(**)()>::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 00000000..a02f0092 --- /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 <boost/callable_traits/detail/config.hpp> + + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +#include <boost/callable_traits/add_transaction_safe.hpp> +#include "test.hpp" + +template<typename Safe, typename NotSafe> +void test() { + + CT_ASSERT(std::is_same<Safe, TRAIT(add_transaction_safe, NotSafe)>::value); + + //sanity check + CT_ASSERT(!std::is_same<Safe, NotSafe>::value); +} + +#define TEST_TRANSACTION_SAFE(not_safe) test<not_safe transaction_safe, not_safe>() + +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 00000000..bb74cdc1 --- /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 <boost/callable_traits/add_transaction_safe.hpp> +#include <tuple> +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +struct foo; + +template<typename T> +struct is_substitution_failure_add_tx_safe { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(add_transaction_safe, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_add_tx_safe<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int &>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int (* const &)()>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int (foo::* &)()>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int (foo::* const)()>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int (foo::* const &)()>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<void>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<void*>::value); + CT_ASSERT(is_substitution_failure_add_tx_safe<void(**)()>::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 00000000..c1d0ca05 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/add_varargs.hpp> +#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<va_f, TRAIT(add_varargs, f)>{}); + CT_ASSERT(std::is_same<va_l, TRAIT(add_varargs, l)>{}); + CT_ASSERT(std::is_same<va_r, TRAIT(add_varargs, r)>{}); + CT_ASSERT(std::is_same<va_c, TRAIT(add_varargs, c)>{}); + CT_ASSERT(std::is_same<va_cl, TRAIT(add_varargs, cl)>{}); + CT_ASSERT(std::is_same<va_cr, TRAIT(add_varargs, cr)>{}); + CT_ASSERT(std::is_same<va_v, TRAIT(add_varargs, v)>{}); + CT_ASSERT(std::is_same<va_vl, TRAIT(add_varargs, vl)>{}); + CT_ASSERT(std::is_same<va_vr, TRAIT(add_varargs, vr)>{}); + CT_ASSERT(std::is_same<va_cv, TRAIT(add_varargs, cv)>{}); + CT_ASSERT(std::is_same<va_cvl, TRAIT(add_varargs, cvl)>{}); + CT_ASSERT(std::is_same<va_cvr, TRAIT(add_varargs, cvr)>{}); + + CT_ASSERT(std::is_same<va_f, TRAIT(add_varargs, va_f)>{}); + CT_ASSERT(std::is_same<va_l, TRAIT(add_varargs, va_l)>{}); + CT_ASSERT(std::is_same<va_r, TRAIT(add_varargs, va_r)>{}); + CT_ASSERT(std::is_same<va_c, TRAIT(add_varargs, va_c)>{}); + CT_ASSERT(std::is_same<va_cl, TRAIT(add_varargs, va_cl)>{}); + CT_ASSERT(std::is_same<va_cr, TRAIT(add_varargs, va_cr)>{}); + CT_ASSERT(std::is_same<va_v, TRAIT(add_varargs, va_v)>{}); + CT_ASSERT(std::is_same<va_vl, TRAIT(add_varargs, va_vl)>{}); + CT_ASSERT(std::is_same<va_vr, TRAIT(add_varargs, va_vr)>{}); + CT_ASSERT(std::is_same<va_cv, TRAIT(add_varargs, va_cv)>{}); + CT_ASSERT(std::is_same<va_cvl, TRAIT(add_varargs, va_cvl)>{}); + CT_ASSERT(std::is_same<va_cvr, TRAIT(add_varargs, va_cvr)>{}); + } + + { + 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<va_f, TRAIT(add_varargs, f)>{}); + CT_ASSERT(std::is_same<va_l, TRAIT(add_varargs, l)>{}); + CT_ASSERT(std::is_same<va_r, TRAIT(add_varargs, r)>{}); + CT_ASSERT(std::is_same<va_c, TRAIT(add_varargs, c)>{}); + CT_ASSERT(std::is_same<va_cl, TRAIT(add_varargs, cl)>{}); + CT_ASSERT(std::is_same<va_cr, TRAIT(add_varargs, cr)>{}); + CT_ASSERT(std::is_same<va_v, TRAIT(add_varargs, v)>{}); + CT_ASSERT(std::is_same<va_vl, TRAIT(add_varargs, vl)>{}); + CT_ASSERT(std::is_same<va_vr, TRAIT(add_varargs, vr)>{}); + CT_ASSERT(std::is_same<va_cv, TRAIT(add_varargs, cv)>{}); + CT_ASSERT(std::is_same<va_cvl, TRAIT(add_varargs, cvl)>{}); + CT_ASSERT(std::is_same<va_cvr, TRAIT(add_varargs, cvr)>{}); + + CT_ASSERT(std::is_same<va_f, TRAIT(add_varargs, va_f)>{}); + CT_ASSERT(std::is_same<va_l, TRAIT(add_varargs, va_l)>{}); + CT_ASSERT(std::is_same<va_r, TRAIT(add_varargs, va_r)>{}); + CT_ASSERT(std::is_same<va_c, TRAIT(add_varargs, va_c)>{}); + CT_ASSERT(std::is_same<va_cl, TRAIT(add_varargs, va_cl)>{}); + CT_ASSERT(std::is_same<va_cr, TRAIT(add_varargs, va_cr)>{}); + CT_ASSERT(std::is_same<va_v, TRAIT(add_varargs, va_v)>{}); + CT_ASSERT(std::is_same<va_vl, TRAIT(add_varargs, va_vl)>{}); + CT_ASSERT(std::is_same<va_vr, TRAIT(add_varargs, va_vr)>{}); + CT_ASSERT(std::is_same<va_cv, TRAIT(add_varargs, va_cv)>{}); + CT_ASSERT(std::is_same<va_cvl, TRAIT(add_varargs, va_cvl)>{}); + CT_ASSERT(std::is_same<va_cvr, TRAIT(add_varargs, va_cvr)>{}); + } + +#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<va_f, TRAIT(add_varargs, f)>{}); + CT_ASSERT(std::is_same<va_l, TRAIT(add_varargs, l)>{}); + CT_ASSERT(std::is_same<va_r, TRAIT(add_varargs, r)>{}); + CT_ASSERT(std::is_same<va_c, TRAIT(add_varargs, c)>{}); + CT_ASSERT(std::is_same<va_cl, TRAIT(add_varargs, cl)>{}); + CT_ASSERT(std::is_same<va_cr, TRAIT(add_varargs, cr)>{}); + CT_ASSERT(std::is_same<va_v, TRAIT(add_varargs, v)>{}); + CT_ASSERT(std::is_same<va_vl, TRAIT(add_varargs, vl)>{}); + CT_ASSERT(std::is_same<va_vr, TRAIT(add_varargs, vr)>{}); + CT_ASSERT(std::is_same<va_cv, TRAIT(add_varargs, cv)>{}); + CT_ASSERT(std::is_same<va_cvl, TRAIT(add_varargs, cvl)>{}); + CT_ASSERT(std::is_same<va_cvr, TRAIT(add_varargs, cvr)>{}); + + CT_ASSERT(std::is_same<va_f, TRAIT(add_varargs, va_f)>{}); + CT_ASSERT(std::is_same<va_l, TRAIT(add_varargs, va_l)>{}); + CT_ASSERT(std::is_same<va_r, TRAIT(add_varargs, va_r)>{}); + CT_ASSERT(std::is_same<va_c, TRAIT(add_varargs, va_c)>{}); + CT_ASSERT(std::is_same<va_cl, TRAIT(add_varargs, va_cl)>{}); + CT_ASSERT(std::is_same<va_cr, TRAIT(add_varargs, va_cr)>{}); + CT_ASSERT(std::is_same<va_v, TRAIT(add_varargs, va_v)>{}); + CT_ASSERT(std::is_same<va_vl, TRAIT(add_varargs, va_vl)>{}); + CT_ASSERT(std::is_same<va_vr, TRAIT(add_varargs, va_vr)>{}); + CT_ASSERT(std::is_same<va_cv, TRAIT(add_varargs, va_cv)>{}); + CT_ASSERT(std::is_same<va_cvl, TRAIT(add_varargs, va_cvl)>{}); + CT_ASSERT(std::is_same<va_cvr, TRAIT(add_varargs, va_cvr)>{}); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(&)(); + using va_f = void(&)(...); + CT_ASSERT(std::is_same<va_f, TRAIT(add_varargs, f)>{}); + } +} 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 00000000..baa63dcd --- /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 <boost/callable_traits/add_varargs.hpp> +#include <tuple> +#include "test.hpp" + +struct foo; + +template<typename T> +struct is_substitution_failure_add_varargs { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(add_varargs, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_add_varargs<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_add_varargs<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int &>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int (* const &)()>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int (foo::* &)()>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int (foo::* const)()>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int (foo::* const &)()>::value); + CT_ASSERT(is_substitution_failure_add_varargs<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_add_varargs<void>::value); + CT_ASSERT(is_substitution_failure_add_varargs<void*>::value); + CT_ASSERT(is_substitution_failure_add_varargs<void(**)()>::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 00000000..3b896aa3 --- /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 <boost/callable_traits/apply_member_pointer.hpp> +#include "test.hpp" + +struct foo; + +template<typename T, typename U> +struct is_substitution_failure_apply_member_pointer { + + template<typename, typename> + static auto test(...) -> std::true_type; + + template<typename A, typename B, + typename std::remove_reference< + TRAIT(apply_member_pointer, A, B)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T, U>(0))::value; +}; + +int main() { + CT_ASSERT(is_substitution_failure_apply_member_pointer<void, foo>::value); + CT_ASSERT(is_substitution_failure_apply_member_pointer<int, int>::value); + CT_ASSERT(is_substitution_failure_apply_member_pointer<void, int>::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 00000000..e09d4734 --- /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 <boost/callable_traits/apply_member_pointer.hpp> +#include "test.hpp" + +struct foo; + +template<typename Input, typename Output> +void test_case() { + assert_same<TRAIT(apply_member_pointer, Input, foo), Output>(); +} + +int main() { + + test_case<int(), int(foo::*)() >(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case<int() TX_SAFE, int(foo::*)() TX_SAFE >(); + test_case<int() LREF, int(foo::*)() LREF >(); + test_case<int() LREF TX_SAFE, int(foo::*)() LREF TX_SAFE >(); + test_case<int() RREF, int(foo::*)() RREF >(); + test_case<int() RREF TX_SAFE, int(foo::*)() RREF TX_SAFE >(); + test_case<int() const, int(foo::*)() const >(); + test_case<int() const TX_SAFE, int(foo::*)() const TX_SAFE >(); + test_case<int() const LREF, int(foo::*)() const LREF >(); + test_case<int() const LREF TX_SAFE, int(foo::*)() const LREF TX_SAFE >(); + test_case<int() const RREF, int(foo::*)() const RREF >(); + test_case<int() const RREF TX_SAFE, int(foo::*)() const RREF TX_SAFE >(); + test_case<int() volatile, int(foo::*)() volatile >(); + test_case<int() volatile TX_SAFE, int(foo::*)() volatile TX_SAFE >(); + test_case<int() volatile LREF, int(foo::*)() volatile LREF >(); + test_case<int() volatile LREF TX_SAFE, int(foo::*)() volatile LREF TX_SAFE >(); + test_case<int() volatile RREF, int(foo::*)() volatile RREF >(); + test_case<int() volatile RREF TX_SAFE, int(foo::*)() volatile RREF TX_SAFE >(); +#endif + + test_case<int(int), int(foo::*)(int) >(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case<int(int) TX_SAFE, int(foo::*)(int) TX_SAFE >(); + test_case<int(int) LREF, int(foo::*)(int) LREF >(); + test_case<int(int) LREF TX_SAFE, int(foo::*)(int) LREF TX_SAFE >(); + test_case<int(int) RREF, int(foo::*)(int) RREF >(); + test_case<int(int) RREF TX_SAFE, int(foo::*)(int) RREF TX_SAFE >(); + test_case<int(int) const, int(foo::*)(int) const >(); + test_case<int(int) const TX_SAFE, int(foo::*)(int) const TX_SAFE >(); + test_case<int(int) const LREF, int(foo::*)(int) const LREF >(); + test_case<int(int) const LREF TX_SAFE, int(foo::*)(int) const LREF TX_SAFE >(); + test_case<int(int) const RREF, int(foo::*)(int) const RREF >(); + test_case<int(int) const RREF TX_SAFE, int(foo::*)(int) const RREF TX_SAFE >(); + test_case<int(int) volatile, int(foo::*)(int) volatile >(); + test_case<int(int) volatile TX_SAFE, int(foo::*)(int) volatile TX_SAFE >(); + test_case<int(int) volatile LREF, int(foo::*)(int) volatile LREF >(); + test_case<int(int) volatile LREF TX_SAFE, int(foo::*)(int) volatile LREF TX_SAFE >(); + test_case<int(int) volatile RREF, int(foo::*)(int) volatile RREF >(); + test_case<int(int) volatile RREF TX_SAFE, int(foo::*)(int) volatile RREF TX_SAFE >(); +#endif + +//MSVC doesn't like varargs on abominable functions +#ifndef BOOST_CLBL_TRTS_MSVC + + test_case<int(...), int(foo::*)(...) >(); + + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case<int(...) TX_SAFE, int(foo::*)(...) TX_SAFE >(); + test_case<int(...) LREF, int(foo::*)(...) LREF >(); + test_case<int(...) LREF TX_SAFE, int(foo::*)(...) LREF TX_SAFE >(); + test_case<int(...) RREF, int(foo::*)(...) RREF >(); + test_case<int(...) RREF TX_SAFE, int(foo::*)(...) RREF TX_SAFE >(); + test_case<int(...) const, int(foo::*)(...) const >(); + test_case<int(...) const TX_SAFE, int(foo::*)(...) const TX_SAFE >(); + test_case<int(...) const LREF, int(foo::*)(...) const LREF >(); + test_case<int(...) const LREF TX_SAFE, int(foo::*)(...) const LREF TX_SAFE >(); + test_case<int(...) const RREF, int(foo::*)(...) const RREF >(); + test_case<int(...) const RREF TX_SAFE, int(foo::*)(...) const RREF TX_SAFE >(); + test_case<int(...) volatile, int(foo::*)(...) volatile >(); + test_case<int(...) volatile TX_SAFE, int(foo::*)(...) volatile TX_SAFE >(); + test_case<int(...) volatile LREF, int(foo::*)(...) volatile LREF >(); + test_case<int(...) volatile LREF TX_SAFE, int(foo::*)(...) volatile LREF TX_SAFE >(); + test_case<int(...) volatile RREF, int(foo::*)(...) volatile RREF >(); + test_case<int(...) volatile RREF TX_SAFE, int(foo::*)(...) volatile RREF TX_SAFE >(); +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + test_case<int(int, ...), int(foo::*)(int, ...) >(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + test_case<int(int, ...) TX_SAFE, int(foo::*)(int, ...) TX_SAFE >(); + test_case<int(int, ...) LREF, int(foo::*)(int, ...) LREF >(); + test_case<int(int, ...) LREF TX_SAFE, int(foo::*)(int, ...) LREF TX_SAFE >(); + test_case<int(int, ...) RREF, int(foo::*)(int, ...) RREF >(); + test_case<int(int, ...) RREF TX_SAFE, int(foo::*)(int, ...) RREF TX_SAFE >(); + test_case<int(int, ...) const, int(foo::*)(int, ...) const >(); + test_case<int(int, ...) const TX_SAFE, int(foo::*)(int, ...) const TX_SAFE >(); + test_case<int(int, ...) const LREF, int(foo::*)(int, ...) const LREF >(); + test_case<int(int, ...) const LREF TX_SAFE, int(foo::*)(int, ...) const LREF TX_SAFE >(); + test_case<int(int, ...) const RREF, int(foo::*)(int, ...) const RREF >(); + test_case<int(int, ...) const RREF TX_SAFE, int(foo::*)(int, ...) const RREF TX_SAFE >(); + test_case<int(int, ...) volatile, int(foo::*)(int, ...) volatile >(); + test_case<int(int, ...) volatile TX_SAFE, int(foo::*)(int, ...) volatile TX_SAFE >(); + test_case<int(int, ...) volatile LREF, int(foo::*)(int, ...) volatile LREF >(); + test_case<int(int, ...) volatile LREF TX_SAFE, int(foo::*)(int, ...) volatile LREF TX_SAFE >(); + test_case<int(int, ...) volatile RREF, int(foo::*)(int, ...) volatile RREF >(); + test_case<int(int, ...) volatile RREF TX_SAFE, int(foo::*)(int, ...) volatile RREF TX_SAFE >(); +#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 00000000..9395ff49 --- /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 <boost/callable_traits/apply_member_pointer.hpp> +#include "test.hpp" + +struct foo; + +template<typename Input, typename Output> +void test_case() { + assert_same<TRAIT(apply_member_pointer, Input, foo), Output>(); +} + +int main() { + test_case<int, int foo::*>(); + test_case<int &, int foo::*>(); + test_case<int const, int const foo::*>(); + test_case<int const &, int const foo::*>(); + test_case<int volatile, int volatile foo::*>(); + test_case<int volatile &, int volatile foo::*>(); + + //member data - function pointer + test_case<int(* const)(), int(* const foo::*)()>(); + test_case<int(* const &)(), int(* const foo::*)()>(); +} + 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 00000000..8b9eaf22 --- /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 <boost/callable_traits/apply_member_pointer.hpp> +#include "test.hpp" + +struct a; +struct b; + +template<typename Input, typename Output> +void test_case() { + assert_same< TRAIT(apply_member_pointer, Input, b), Output>(); +} + +int main() { + + test_case<int(a::*)(), int(b::*)() >(); + test_case<int(a::*)() TX_SAFE, int(b::*)() TX_SAFE >(); + test_case<int(a::*)() LREF, int(b::*)() LREF >(); + test_case<int(a::*)() LREF TX_SAFE, int(b::*)() LREF TX_SAFE >(); + test_case<int(a::*)() RREF, int(b::*)() RREF >(); + test_case<int(a::*)() RREF TX_SAFE, int(b::*)() RREF TX_SAFE >(); + test_case<int(a::*)() const, int(b::*)() const >(); + test_case<int(a::*)() const TX_SAFE, int(b::*)() const TX_SAFE >(); + test_case<int(a::*)() const LREF, int(b::*)() const LREF >(); + test_case<int(a::*)() const LREF TX_SAFE, int(b::*)() const LREF TX_SAFE >(); + test_case<int(a::*)() const RREF, int(b::*)() const RREF >(); + test_case<int(a::*)() const RREF TX_SAFE, int(b::*)() const RREF TX_SAFE >(); + test_case<int(a::*)() volatile, int(b::*)() volatile >(); + test_case<int(a::*)() volatile TX_SAFE, int(b::*)() volatile TX_SAFE >(); + test_case<int(a::*)() volatile LREF, int(b::*)() volatile LREF >(); + test_case<int(a::*)() volatile LREF TX_SAFE, int(b::*)() volatile LREF TX_SAFE >(); + test_case<int(a::*)() volatile RREF, int(b::*)() volatile RREF >(); + test_case<int(a::*)() volatile RREF TX_SAFE, int(b::*)() volatile RREF TX_SAFE >(); + test_case<int(a::*)(int), int(b::*)(int) >(); + test_case<int(a::*)(int) TX_SAFE, int(b::*)(int) TX_SAFE >(); + test_case<int(a::*)(int) LREF, int(b::*)(int) LREF >(); + test_case<int(a::*)(int) LREF TX_SAFE, int(b::*)(int) LREF TX_SAFE >(); + test_case<int(a::*)(int) RREF, int(b::*)(int) RREF >(); + test_case<int(a::*)(int) RREF TX_SAFE, int(b::*)(int) RREF TX_SAFE >(); + test_case<int(a::*)(int) const, int(b::*)(int) const >(); + test_case<int(a::*)(int) const TX_SAFE, int(b::*)(int) const TX_SAFE >(); + test_case<int(a::*)(int) const LREF, int(b::*)(int) const LREF >(); + test_case<int(a::*)(int) const LREF TX_SAFE, int(b::*)(int) const LREF TX_SAFE >(); + test_case<int(a::*)(int) const RREF, int(b::*)(int) const RREF >(); + test_case<int(a::*)(int) const RREF TX_SAFE, int(b::*)(int) const RREF TX_SAFE >(); + test_case<int(a::*)(int) volatile, int(b::*)(int) volatile >(); + test_case<int(a::*)(int) volatile TX_SAFE, int(b::*)(int) volatile TX_SAFE >(); + test_case<int(a::*)(int) volatile LREF, int(b::*)(int) volatile LREF >(); + test_case<int(a::*)(int) volatile LREF TX_SAFE, int(b::*)(int) volatile LREF TX_SAFE >(); + test_case<int(a::*)(int) volatile RREF, int(b::*)(int) volatile RREF >(); + test_case<int(a::*)(int) volatile RREF TX_SAFE, int(b::*)(int) volatile RREF TX_SAFE >(); + + test_case<int(VA_CC a::*)(...), int(VA_CC b::*)(...) >(); + test_case<int(VA_CC a::*)(...) TX_SAFE, int(VA_CC b::*)(...) TX_SAFE >(); + test_case<int(VA_CC a::*)(...) LREF, int(VA_CC b::*)(...) LREF >(); + test_case<int(VA_CC a::*)(...) LREF TX_SAFE, int(VA_CC b::*)(...) LREF TX_SAFE >(); + test_case<int(VA_CC a::*)(...) RREF, int(VA_CC b::*)(...) RREF >(); + test_case<int(VA_CC a::*)(...) RREF TX_SAFE, int(VA_CC b::*)(...) RREF TX_SAFE >(); + test_case<int(VA_CC a::*)(...) const, int(VA_CC b::*)(...) const >(); + test_case<int(VA_CC a::*)(...) const TX_SAFE, int(VA_CC b::*)(...) const TX_SAFE >(); + test_case<int(VA_CC a::*)(...) const LREF, int(VA_CC b::*)(...) const LREF >(); + test_case<int(VA_CC a::*)(...) const LREF TX_SAFE, int(VA_CC b::*)(...) const LREF TX_SAFE >(); + test_case<int(VA_CC a::*)(...) const RREF, int(VA_CC b::*)(...) const RREF >(); + test_case<int(VA_CC a::*)(...) const RREF TX_SAFE, int(VA_CC b::*)(...) const RREF TX_SAFE >(); + test_case<int(VA_CC a::*)(...) volatile, int(VA_CC b::*)(...) volatile >(); + test_case<int(VA_CC a::*)(...) volatile TX_SAFE, int(VA_CC b::*)(...) volatile TX_SAFE >(); + test_case<int(VA_CC a::*)(...) volatile LREF, int(VA_CC b::*)(...) volatile LREF >(); + test_case<int(VA_CC a::*)(...) volatile LREF TX_SAFE, int(VA_CC b::*)(...) volatile LREF TX_SAFE >(); + test_case<int(VA_CC a::*)(...) volatile RREF, int(VA_CC b::*)(...) volatile RREF >(); + test_case<int(VA_CC a::*)(...) volatile RREF TX_SAFE, int(VA_CC b::*)(...) volatile RREF TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...), int(VA_CC b::*)(int, ...) >(); + test_case<int(VA_CC a::*)(int, ...) TX_SAFE, int(VA_CC b::*)(int, ...) TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) LREF, int(VA_CC b::*)(int, ...) LREF >(); + test_case<int(VA_CC a::*)(int, ...) LREF TX_SAFE, int(VA_CC b::*)(int, ...) LREF TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) RREF, int(VA_CC b::*)(int, ...) RREF >(); + test_case<int(VA_CC a::*)(int, ...) RREF TX_SAFE, int(VA_CC b::*)(int, ...) RREF TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) const, int(VA_CC b::*)(int, ...) const >(); + test_case<int(VA_CC a::*)(int, ...) const TX_SAFE, int(VA_CC b::*)(int, ...) const TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) const LREF, int(VA_CC b::*)(int, ...) const LREF >(); + test_case<int(VA_CC a::*)(int, ...) const LREF TX_SAFE, int(VA_CC b::*)(int, ...) const LREF TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) const RREF, int(VA_CC b::*)(int, ...) const RREF >(); + test_case<int(VA_CC a::*)(int, ...) const RREF TX_SAFE, int(VA_CC b::*)(int, ...) const RREF TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) volatile, int(VA_CC b::*)(int, ...) volatile >(); + test_case<int(VA_CC a::*)(int, ...) volatile TX_SAFE, int(VA_CC b::*)(int, ...) volatile TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) volatile LREF, int(VA_CC b::*)(int, ...) volatile LREF >(); + test_case<int(VA_CC a::*)(int, ...) volatile LREF TX_SAFE, int(VA_CC b::*)(int, ...) volatile LREF TX_SAFE >(); + test_case<int(VA_CC a::*)(int, ...) volatile RREF, int(VA_CC b::*)(int, ...) volatile RREF >(); + test_case<int(VA_CC a::*)(int, ...) volatile RREF TX_SAFE, int(VA_CC b::*)(int, ...) volatile RREF TX_SAFE >(); +} 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 00000000..b3f5138a --- /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 <type_traits> +#include <cstdint> +#include <memory> +#include <boost/callable_traits.hpp> +#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<args_t, std::tuple<foo1&, char, float&, int>>{}); + } { + using pmf = decltype(&foo2::bar); + using args_t = TRAIT(args, pmf); + CT_ASSERT(is_same<args_t, std::tuple<foo2&, char, float&, int>>{}); + } { + using args_t = TRAIT(args, foo3); + CT_ASSERT(is_same<args_t, std::tuple<char, float&, int>>{}); + } { + using args_t = TRAIT(args, foo4); + CT_ASSERT(is_same<args_t, std::tuple<char, float&, int>>{}); + } { + using args_t = TRAIT(args, decltype(foo5)); + CT_ASSERT(is_same<args_t, std::tuple<char, float&, int>>{}); + } { + using args_t = TRAIT(args, decltype(foo6)); + CT_ASSERT(is_same<args_t, std::tuple<char, float&, int>>{}); + } + + 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 00000000..ef651cdb --- /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 <boost/callable_traits/args.hpp> +#include "test.hpp" + +struct foo; + +template<typename T> +struct is_substitution_failure_args { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename U, + TRAIT(boost::callable_traits::args, U, std::tuple)* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + CT_ASSERT(is_substitution_failure_args<int>::value); + CT_ASSERT(is_substitution_failure_args<int &>::value); + CT_ASSERT(is_substitution_failure_args<int (** const &)()>::value); + CT_ASSERT(is_substitution_failure_args<int (foo::** &)()>::value); + CT_ASSERT(is_substitution_failure_args<int (foo::** const)()>::value); + CT_ASSERT(is_substitution_failure_args<int (foo::** const &)()>::value); + CT_ASSERT(is_substitution_failure_args<int (foo::** volatile)()>::value); + CT_ASSERT(!is_substitution_failure_args<int (* const &)()>::value); + CT_ASSERT(!is_substitution_failure_args<int (foo::* &)()>::value); + CT_ASSERT(!is_substitution_failure_args<int (foo::* const)()>::value); + CT_ASSERT(!is_substitution_failure_args<int (foo::* const &)()>::value); + CT_ASSERT(!is_substitution_failure_args<int (foo::* volatile)()>::value); + auto lambda = [](){}; + CT_ASSERT(!is_substitution_failure_args<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_args<void>::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 00000000..2048a33f --- /dev/null +++ b/src/boost/libs/callable_traits/test/class_of.cpp @@ -0,0 +1,52 @@ +#include <tuple> +#include <utility> +#include <type_traits> +#include <boost/callable_traits/class_of.hpp> +#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<test, expect>::value); + } + + { + using f = void(foo::*)() const; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same<test, expect>::value); + } + + { + using f = void(foo::*)() volatile; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same<test, expect>::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<test, expect>::value); + } + + { + using f = int foo::*; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same<test, expect>::value); + } + + { + using f = const int foo::*; + using test = TRAIT(class_of, f); + using expect = foo; + CT_ASSERT(std::is_same<test, expect>::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 00000000..225a0359 --- /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 <boost/callable_traits/class_of.hpp> +#include "test.hpp" + +struct foo; + +template<typename T> +struct is_substitution_failure_class_of { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(class_of, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_class_of<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_class_of<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_class_of<void>::value); + CT_ASSERT(is_substitution_failure_class_of<void*>::value); + CT_ASSERT(is_substitution_failure_class_of<int>::value); + CT_ASSERT(is_substitution_failure_class_of<int &>::value); + CT_ASSERT(is_substitution_failure_class_of<int()>::value); + CT_ASSERT(is_substitution_failure_class_of<int(*)()>::value); + CT_ASSERT(is_substitution_failure_class_of<int(**)()>::value); + CT_ASSERT(is_substitution_failure_class_of<int(&)()>::value); + CT_ASSERT(is_substitution_failure_class_of<int (foo::** const)()>::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 00000000..9ad52448 --- /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 <type_traits> +#include <boost/callable_traits/detail/qualifier_flags.hpp> +#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<rref_, lref_>; + CT_ASSERT(rref_plus_lref::value == lref_); + + using lref_plus_rref = collapse_flags<lref_, rref_>; + CT_ASSERT(lref_plus_rref::value == lref_); + + using lref_plus_lref = collapse_flags<lref_, lref_>; + CT_ASSERT(lref_plus_lref::value == lref_); + + using rref_plus_rref = collapse_flags<rref_, rref_>; + CT_ASSERT(rref_plus_rref::value == rref_); + + using const_plus_rref = collapse_flags<const_, rref_>; + CT_ASSERT(const_plus_rref::value == (const_ | rref_)); + + using const_plus_lref = collapse_flags<const_, lref_>; + 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 00000000..98fa1af8 --- /dev/null +++ b/src/boost/libs/callable_traits/test/function_type.cpp @@ -0,0 +1,96 @@ + +#include <boost/callable_traits/function_type.hpp> +#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<TRAIT(function_type, G), F>::value); + CT_ASSERT(std::is_same<function_type_t<G const &>, F>::value); + CT_ASSERT(std::is_same<function_type_t<G const &&>, F>::value); + CT_ASSERT(std::is_same<function_type_t<G volatile &>, F>::value); + CT_ASSERT(std::is_same<function_type_t<G &>, F>::value); + CT_ASSERT(std::is_same<function_type_t<G &&>, F>::value); + CT_ASSERT(std::is_same<function_type_t< + decltype(&G::operator())>, 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<TRAIT(function_type, G), F>::value); + } +#endif + + { + using G = void (*)(int, char) BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER; + using F = void (int, char); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + using G = void (* const &)(int, char); + using F = void (int, char); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + using G = int (* &&)(); + using F = int (); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + using G = int (* &&)(); + using F = int (); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + using G = char const * const & (&)(...); + using F = char const * const & (...); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + struct G { int operator() (...) volatile; }; + using F = int (...); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + struct G { int operator() (...) volatile BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; }; + using F = int (...); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + struct G { int operator() (...) const BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; }; + using F = int (...); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::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<TRAIT(function_type, G), F>::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<TRAIT(function_type, G), F>::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<TRAIT(function_type, G), F>::value); + }{ + using G = void (foo::*)(int, int, int); + using F = void (foo &, int, int, int); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::value); + }{ + using G = void (foo::*)() BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; + using F = void (foo &); + CT_ASSERT(std::is_same<TRAIT(function_type, G), F>::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<TRAIT(function_type, G), F>::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<TRAIT(function_type, G), F>::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 00000000..99570dfe --- /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 <boost/callable_traits/function_type.hpp> +#include "test.hpp" + +struct foo; + +template<typename T> +struct is_substitution_failure_function_type { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(function_type, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + CT_ASSERT(is_substitution_failure_function_type<int>::value); + CT_ASSERT(is_substitution_failure_function_type<int &>::value); + CT_ASSERT(is_substitution_failure_function_type<int (foo::** &)()>::value); + CT_ASSERT(is_substitution_failure_function_type<int (foo::** const)()>::value); + CT_ASSERT(is_substitution_failure_function_type<int (foo::** const &)()>::value); + CT_ASSERT(is_substitution_failure_function_type<int (foo::** volatile)()>::value); + CT_ASSERT(!is_substitution_failure_function_type<int (foo::* &)()>::value); + CT_ASSERT(!is_substitution_failure_function_type<int (foo::* const)()>::value); + CT_ASSERT(!is_substitution_failure_function_type<int (foo::* const &)()>::value); + CT_ASSERT(!is_substitution_failure_function_type<int (foo::* volatile)()>::value); + + auto lambda = [](){}; + CT_ASSERT(!is_substitution_failure_function_type<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_function_type<void>::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 00000000..9f80c28b --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/has_member_qualifiers.hpp> +#include "test.hpp" + + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main() { return 0; } +#else + +struct foo {}; + +template<typename T> +void assert_qualified() { + CT_ASSERT( has_member_qualifiers<T>::value); +} + + +template<typename T> +void assert_unqualified() { + CT_ASSERT(! has_member_qualifiers<T>::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<f>(); + assert_qualified<l>(); + assert_qualified<r>(); + assert_qualified<c>(); + assert_qualified<cl>(); + assert_qualified<cr>(); + assert_qualified<v>(); + assert_qualified<vl>(); + assert_qualified<vr>(); + assert_qualified<cv>(); + assert_qualified<cvl>(); + assert_qualified<cvr>(); + } + + { + 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<f>(); + assert_qualified<l>(); + assert_qualified<r>(); + assert_qualified<c>(); + assert_qualified<cl>(); + assert_qualified<cr>(); + assert_qualified<v>(); + assert_qualified<vl>(); + assert_qualified<vr>(); + assert_qualified<cv>(); + assert_qualified<cvl>(); + assert_qualified<cvr>(); + } + +#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<f>()); + CT_ASSERT( has_member_qualifiers<l>()); + CT_ASSERT( has_member_qualifiers<r>()); + CT_ASSERT( has_member_qualifiers<c>()); + CT_ASSERT( has_member_qualifiers<cl>()); + CT_ASSERT( has_member_qualifiers<cr>()); + CT_ASSERT( has_member_qualifiers<v>()); + CT_ASSERT( has_member_qualifiers<vl>()); + CT_ASSERT( has_member_qualifiers<vr>()); + CT_ASSERT( has_member_qualifiers<cv>()); + CT_ASSERT( has_member_qualifiers<cvl>()); + CT_ASSERT( has_member_qualifiers<cvr>()); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + using f_ptr = void(*)(); + assert_unqualified<f_ptr>(); + assert_unqualified<f_ptr foo::*>(); + assert_unqualified<int foo::*>(); + assert_unqualified<void(&)()>(); +} + +#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 00000000..c6717c98 --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/has_member_qualifiers.hpp> +#include "test.hpp" + + + +struct foo {}; + +template<typename T> +void assert_qualified() { + CT_ASSERT( has_member_qualifiers<T>::value); +} + +template<typename T> +void assert_unqualified() { + CT_ASSERT(! has_member_qualifiers<T>::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<f>(); + assert_qualified<c>(); + assert_qualified<v>(); + assert_qualified<cv>(); + } + + { + 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<f>(); + assert_qualified<c>(); + assert_qualified<v>(); + assert_qualified<cv>(); + } + + using f_ptr = void(*)(); + assert_unqualified<f_ptr>(); + assert_unqualified<f_ptr foo::*>(); + assert_unqualified<int foo::*>(); + assert_unqualified<void(&)()>(); +} 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 00000000..b187a6fb --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/has_varargs.hpp> +#include "test.hpp" + +struct foo {}; + +template<typename T> +void assert_has_varargs() { + + CT_ASSERT( has_varargs<T>::value); +} + +template<typename T> +void assert_not_has_varargs() { + + CT_ASSERT(! has_varargs<T>::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<f>(); + assert_not_has_varargs<l>(); + assert_not_has_varargs<r>(); + assert_not_has_varargs<c>(); + assert_not_has_varargs<cl>(); + assert_not_has_varargs<cr>(); + assert_not_has_varargs<v>(); + assert_not_has_varargs<vl>(); + assert_not_has_varargs<vr>(); + assert_not_has_varargs<cv>(); + assert_not_has_varargs<cvl>(); + assert_not_has_varargs<cvr>(); + } + + { + //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<f>(); + } + + { + 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<f>(); + assert_has_varargs<l>(); + assert_has_varargs<r>(); + assert_has_varargs<c>(); + assert_has_varargs<cl>(); + assert_has_varargs<cr>(); + assert_has_varargs<v>(); + assert_has_varargs<vl>(); + assert_has_varargs<vr>(); + assert_has_varargs<cv>(); + assert_has_varargs<cvl>(); + assert_has_varargs<cvr>(); + } + + { + 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<f>(); + assert_not_has_varargs<l>(); + assert_not_has_varargs<r>(); + assert_not_has_varargs<c>(); + assert_not_has_varargs<cl>(); + assert_not_has_varargs<cr>(); + assert_not_has_varargs<v>(); + assert_not_has_varargs<vl>(); + assert_not_has_varargs<vr>(); + assert_not_has_varargs<cv>(); + assert_not_has_varargs<cvl>(); + assert_not_has_varargs<cvr>(); + } + + { + 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<f>(); + assert_has_varargs<l>(); + assert_has_varargs<r>(); + assert_has_varargs<c>(); + assert_has_varargs<cl>(); + assert_has_varargs<cr>(); + assert_has_varargs<v>(); + assert_has_varargs<vl>(); + assert_has_varargs<vr>(); + assert_has_varargs<cv>(); + assert_has_varargs<cvl>(); + assert_has_varargs<cvr>(); + } + +#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<f>()); + CT_ASSERT(! has_varargs<l>()); + CT_ASSERT(! has_varargs<r>()); + CT_ASSERT(! has_varargs<c>()); + CT_ASSERT(! has_varargs<cl>()); + CT_ASSERT(! has_varargs<cr>()); + CT_ASSERT(! has_varargs<v>()); + CT_ASSERT(! has_varargs<vl>()); + CT_ASSERT(! has_varargs<vr>()); + CT_ASSERT(! has_varargs<cv>()); + CT_ASSERT(! has_varargs<cvl>()); + CT_ASSERT(! has_varargs<cvr>()); + } + + { + 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<f>()); + CT_ASSERT( has_varargs<l>()); + CT_ASSERT( has_varargs<r>()); + CT_ASSERT( has_varargs<c>()); + CT_ASSERT( has_varargs<cl>()); + CT_ASSERT( has_varargs<cr>()); + CT_ASSERT( has_varargs<v>()); + CT_ASSERT( has_varargs<vl>()); + CT_ASSERT( has_varargs<vr>()); + CT_ASSERT( has_varargs<cv>()); + CT_ASSERT( has_varargs<cvl>()); + CT_ASSERT( has_varargs<cvr>()); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + assert_not_has_varargs<void(*)()>(); + assert_has_varargs<void(*)(...)>(); + assert_not_has_varargs<void(&)()>(); + assert_has_varargs<void(&)(...)>(); +} 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 00000000..416ccdc1 --- /dev/null +++ b/src/boost/libs/callable_traits/test/has_void_return.cpp @@ -0,0 +1,58 @@ +#include <tuple> +#include <utility> +#include <type_traits> +#include <boost/callable_traits/has_void_return.hpp> +#include "test.hpp" + +struct foo; + +template<typename T> +void assert_void_return() { + CT_ASSERT(has_void_return<T>::value); +} + +template<typename T> +void assert_not_void_return() { + CT_ASSERT(!has_void_return<T>::value); +} + +int main() { + + assert_void_return<void()>(); + assert_void_return<void(...)>(); + +#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + assert_void_return<void(int) const>(); + assert_void_return<void(int) volatile>(); + assert_void_return<void(int) const volatile>(); +#endif // #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + assert_void_return<void(foo::*)()>(); + assert_void_return<void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(int, ...)>(); + assert_void_return<void(foo::*)(int) const>(); + assert_void_return<void(foo::*)() volatile>(); + assert_void_return<void(foo::*)(int) const volatile>(); + + assert_void_return<void(*)()>(); + assert_void_return<void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC *)(int, ...)>(); + + assert_void_return<void(&)(int)>(); + assert_void_return<void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC &)(...)>(); + + auto lambda = []{}; + assert_void_return<decltype(lambda)>(); + + assert_not_void_return<void>(); + assert_not_void_return<int>(); + assert_not_void_return<void*>(); + assert_not_void_return<void* foo::*>(); + assert_not_void_return<void(** const)()>(); + assert_not_void_return<int()>(); + assert_not_void_return<int(*)()>(); + assert_not_void_return<int(&)()>(); + assert_not_void_return<int(foo::*)()>(); + assert_not_void_return<int(foo::*)() const>(); + assert_not_void_return<int(foo::*)() volatile>(); + assert_not_void_return<int(foo::*)() const volatile>(); + assert_not_void_return<void(foo::**)()>(); +} 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 00000000..5f9c0490 --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_const_member.hpp> +#include "test.hpp" + +struct foo {}; + +template<typename T> +void assert_const_qualified() { + CT_ASSERT( is_const_member<T>()); +} + + +template<typename T> +void assert_not_const_qualified() { + CT_ASSERT(! is_const_member<T>()); +} + +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<f>(); + assert_not_const_qualified<l>(); + assert_not_const_qualified<r>(); + assert_const_qualified<c>(); + assert_const_qualified<cl>(); + assert_const_qualified<cr>(); + assert_not_const_qualified<v>(); + assert_not_const_qualified<vl>(); + assert_not_const_qualified<vr>(); + assert_const_qualified<cv>(); + assert_const_qualified<cvl>(); + assert_const_qualified<cvr>(); + } + + { + 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<f>(); + assert_not_const_qualified<l>(); + assert_not_const_qualified<r>(); + assert_const_qualified<c>(); + assert_const_qualified<cl>(); + assert_const_qualified<cr>(); + assert_not_const_qualified<v>(); + assert_not_const_qualified<vl>(); + assert_not_const_qualified<vr>(); + assert_const_qualified<cv>(); + assert_const_qualified<cvl>(); + assert_const_qualified<cvr>(); + } + +#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<f>()); + CT_ASSERT(! is_const_member<l>()); + CT_ASSERT(! is_const_member<r>()); + CT_ASSERT( is_const_member<c>()); + CT_ASSERT( is_const_member<cl>()); + CT_ASSERT( is_const_member<cr>()); + CT_ASSERT(! is_const_member<v>()); + CT_ASSERT(! is_const_member<vl>()); + CT_ASSERT(! is_const_member<vr>()); + CT_ASSERT( is_const_member<cv>()); + CT_ASSERT( is_const_member<cvl>()); + CT_ASSERT( is_const_member<cvr>()); + } + +#endif + + using f_ptr = void(*)(); + assert_not_const_qualified<f_ptr>(); + assert_not_const_qualified<f_ptr foo::*>(); + assert_not_const_qualified<int foo::*>(); + assert_not_const_qualified<void(&)()>(); +} 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 00000000..b1af7558 --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_cv_member.hpp> +#include "test.hpp" + +struct foo {}; + +template<typename T> +void assert_cv_qualified() { + CT_ASSERT( is_cv_member<T>()); +} + + +template<typename T> +void assert_not_cv_qualified() { + CT_ASSERT(! is_cv_member<T>()); +} + +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<f>(); + assert_not_cv_qualified<l>(); + assert_not_cv_qualified<r>(); + assert_not_cv_qualified<c>(); + assert_not_cv_qualified<cl>(); + assert_not_cv_qualified<cr>(); + assert_not_cv_qualified<v>(); + assert_not_cv_qualified<vl>(); + assert_not_cv_qualified<vr>(); + assert_cv_qualified<cv>(); + assert_cv_qualified<cvl>(); + assert_cv_qualified<cvr>(); + } + + { + 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<f>(); + assert_not_cv_qualified<l>(); + assert_not_cv_qualified<r>(); + assert_not_cv_qualified<c>(); + assert_not_cv_qualified<cl>(); + assert_not_cv_qualified<cr>(); + assert_not_cv_qualified<v>(); + assert_not_cv_qualified<vl>(); + assert_not_cv_qualified<vr>(); + assert_cv_qualified<cv>(); + assert_cv_qualified<cvl>(); + assert_cv_qualified<cvr>(); + } + +#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<f>()); + CT_ASSERT(! is_cv_member<l>()); + CT_ASSERT(! is_cv_member<r>()); + CT_ASSERT(! is_cv_member<c>()); + CT_ASSERT(! is_cv_member<cl>()); + CT_ASSERT(! is_cv_member<cr>()); + CT_ASSERT(! is_cv_member<v>()); + CT_ASSERT(! is_cv_member<vl>()); + CT_ASSERT(! is_cv_member<vr>()); + CT_ASSERT( is_cv_member<cv>()); + CT_ASSERT( is_cv_member<cvl>()); + CT_ASSERT( is_cv_member<cvr>()); + } + +#endif + + using f_ptr = void(*)(); + assert_not_cv_qualified<f_ptr>(); + assert_not_cv_qualified<f_ptr foo::*>(); + assert_not_cv_qualified<int foo::*>(); + assert_not_cv_qualified<void(&)()>(); +} 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 00000000..b9fa0ea4 --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_invocable.hpp> +#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<typename T> +struct tag { + using type = T; +}; + +template<bool Expect, typename... Args> +struct invoke_case { + template<typename Callable> + void operator()(tag<Callable>) 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<Callable, Args...>() == boost::callable_traits::is_invocable<Callable, Args...>())); +#else + CT_ASSERT((Expect == boost::callable_traits::is_invocable<Callable, Args...>())); +#endif + + } +}; + +template<typename Callable, typename... InvokeCases> +void run_tests() { + using ignored = int[]; + ignored x {(InvokeCases{}(tag<Callable>{}),0)..., 0}; + (void)x; +} + +struct foo {}; + +int main() { + + run_tests<void(foo::*)() + ,invoke_case<true, foo> + ,invoke_case<true, foo*> + ,invoke_case<true, foo&> + ,invoke_case<true, foo&&> + ,invoke_case<true, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() LREF + ,invoke_case<false, foo> + ,invoke_case<true, foo*> + ,invoke_case<true, foo&> + ,invoke_case<false, foo&&> + ,invoke_case<true, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() RREF + ,invoke_case<true, foo> + ,invoke_case<false, foo*> + ,invoke_case<false, foo&> + ,invoke_case<true, foo&&> + ,invoke_case<false, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() const + ,invoke_case<true, foo> + ,invoke_case<true, foo*> + ,invoke_case<true, foo&> + ,invoke_case<true, foo&&> + ,invoke_case<true, std::reference_wrapper<foo>> + ,invoke_case<true, foo const> + ,invoke_case<true, foo const*> + ,invoke_case<true, foo const&> + ,invoke_case<true, foo const&&> + ,invoke_case<true, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + +// MSVC doesn't handle cv + ref qualifiers in expression sfinae correctly +#ifndef BOOST_CLBL_TRTS_MSVC + + run_tests<void(foo::*)() const LREF + ,invoke_case<false, foo> + ,invoke_case<true, foo*> + ,invoke_case<true, foo&> + ,invoke_case<false, foo&&> + ,invoke_case<true, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<true, foo const*> + ,invoke_case<true, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<true, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() const RREF + ,invoke_case<true, foo> + ,invoke_case<false, foo*> + ,invoke_case<false, foo&> + ,invoke_case<true, foo&&> + ,invoke_case<false, std::reference_wrapper<foo>> + ,invoke_case<true, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<true, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + +#endif // #ifndef BOOST_CLBL_TRTS_MSVC + + run_tests<int + ,invoke_case<false, foo> + ,invoke_case<false, foo*> + ,invoke_case<false, foo&> + ,invoke_case<false, foo&&> + ,invoke_case<false, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + + auto f = [](int){}; + + run_tests<decltype(f) + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(f)& + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(f)) + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(f))& + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(f))&& + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(f)) const & + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(f)) const && + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(f)&& + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(f) const & + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(f) const && + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + auto g = [](){}; + + run_tests<decltype(g) + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(g)& + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(g)) + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(g))& + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(g))&& + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(g)) const & + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(std::ref(g)) const && + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(g)&& + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(g) const & + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<decltype(g) const && + ,invoke_case<true> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + +// libc++ requires constructible types be passed to std::is_invocable +#ifndef _LIBCPP_VERSION + + run_tests<void(int) + ,invoke_case<true, int> + ,invoke_case<true, char> + ,invoke_case<false, void*> + >(); + + run_tests<void(int) const + ,invoke_case<false, int> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<void() + ,invoke_case<false, int> + ,invoke_case<false, char> + ,invoke_case<false, void*> + >(); + + run_tests<void + ,invoke_case<false, foo> + ,invoke_case<false, foo*> + ,invoke_case<false, foo&> + ,invoke_case<false, foo&&> + ,invoke_case<false, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); +#endif + + run_tests<int + ,invoke_case<false, foo> + ,invoke_case<false, foo*> + ,invoke_case<false, foo&> + ,invoke_case<false, foo&&> + ,invoke_case<false, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, int> + >(); + + run_tests<void* + ,invoke_case<false, foo> + ,invoke_case<false, foo*> + ,invoke_case<false, foo&> + ,invoke_case<false, foo&&> + ,invoke_case<false, std::reference_wrapper<foo>> + ,invoke_case<false, foo const> + ,invoke_case<false, foo const*> + ,invoke_case<false, foo const&> + ,invoke_case<false, foo const&&> + ,invoke_case<false, std::reference_wrapper<foo const>> + ,invoke_case<false, foo, int> + ,invoke_case<false, foo*, int> + ,invoke_case<false, foo&, int> + ,invoke_case<false, foo&&, int> + ,invoke_case<false, std::reference_wrapper<foo>, 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 00000000..f64de2ec --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_invocable.hpp> +#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<typename T> +struct tag { + using type = T; +}; + +template<bool Expect, typename Ret, typename... Args> +struct invoke_case { + template<typename Callable> + void operator()(tag<Callable>) 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<Ret, Callable, Args...>() == boost::callable_traits::is_invocable_r<Ret, Callable, Args...>())); +#else + CT_ASSERT((Expect == boost::callable_traits::is_invocable_r<Ret, Callable, Args...>())); +#endif + + } +}; + +template<typename Callable, typename... InvokeCases> +void run_tests() { + using ignored = int[]; + ignored x {(InvokeCases{}(tag<Callable>{}),0)..., 0}; + (void)x; +} + +struct foo {}; + +int main() { + + run_tests<void(foo::*)() + ,invoke_case<true, void, foo> + ,invoke_case<true, void, foo*> + ,invoke_case<true, void, foo&> + ,invoke_case<true, void, foo&&> + ,invoke_case<true, void, std::reference_wrapper<foo>> + ,invoke_case<false, int, foo> + ,invoke_case<false, int, foo*> + ,invoke_case<false, int, foo&> + ,invoke_case<false, int, foo&&> + ,invoke_case<false, int, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + ,invoke_case<false, int, foo const> + ,invoke_case<false, int, foo const*> + ,invoke_case<false, int, foo const&> + ,invoke_case<false, int, foo const&&> + ,invoke_case<false, int, std::reference_wrapper<foo const>> + ,invoke_case<false, int, foo, int> + ,invoke_case<false, int, foo*, int> + ,invoke_case<false, int, foo&, int> + ,invoke_case<false, int, foo&&, int> + ,invoke_case<false, int, std::reference_wrapper<foo>, int> + >(); + + run_tests<char(foo::*)() + ,invoke_case<true, void, foo> + ,invoke_case<true, void, foo*> + ,invoke_case<true, void, foo&> + ,invoke_case<true, void, foo&&> + ,invoke_case<true, void, std::reference_wrapper<foo>> + ,invoke_case<true, int, foo> + ,invoke_case<true, int, foo*> + ,invoke_case<true, int, foo&> + ,invoke_case<true, int, foo&&> + ,invoke_case<true, int, std::reference_wrapper<foo>> + >(); + + run_tests<void(foo::*)() LREF + ,invoke_case<false, void, foo> + ,invoke_case<true, void, foo*> + ,invoke_case<true, void, foo&> + ,invoke_case<false, int, foo*> + ,invoke_case<false, int, foo&> + ,invoke_case<false, void, foo&&> + ,invoke_case<true, void, std::reference_wrapper<foo>> + ,invoke_case<false, int, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() RREF + ,invoke_case<true, void, foo> + ,invoke_case<false, int, foo> + ,invoke_case<false, void, foo*> + ,invoke_case<false, void, foo&> + ,invoke_case<true, void, foo&&> + ,invoke_case<false, int, foo&&> + ,invoke_case<false, void, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() const + ,invoke_case<true, void, foo> + ,invoke_case<true, void, foo*> + ,invoke_case<true, void, foo&> + ,invoke_case<true, void, foo&&> + ,invoke_case<true, void, std::reference_wrapper<foo>> + ,invoke_case<true, void, foo const> + ,invoke_case<true, void, foo const*> + ,invoke_case<true, void, foo const&> + ,invoke_case<true, void, foo const&&> + ,invoke_case<true, void, std::reference_wrapper<foo const>> + ,invoke_case<false, int, foo> + ,invoke_case<false, int, foo*> + ,invoke_case<false, int, foo&> + ,invoke_case<false, int, foo&&> + ,invoke_case<false, int, std::reference_wrapper<foo>> + ,invoke_case<false, int, foo const> + ,invoke_case<false, int, foo const*> + ,invoke_case<false, int, foo const&> + ,invoke_case<false, int, foo const&&> + ,invoke_case<false, int, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + +// MSVC doesn't handle cv + ref qualifiers in expression sfinae correctly +#ifndef BOOST_CLBL_TRTS_MSVC + + run_tests<void(foo::*)() const LREF + ,invoke_case<false, void, foo> + ,invoke_case<true, void, foo*> + ,invoke_case<true, void, foo&> + ,invoke_case<false, int, foo*> + ,invoke_case<false, int, foo&> + ,invoke_case<false, void, foo&&> + ,invoke_case<true, void, std::reference_wrapper<foo>> + ,invoke_case<false, int, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<true, void, foo const*> + ,invoke_case<true, void, foo const&> + ,invoke_case<false, int, foo const*> + ,invoke_case<false, int, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<true, void, std::reference_wrapper<foo const>> + ,invoke_case<false, int, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + + run_tests<void(foo::*)() const RREF + ,invoke_case<true, void, foo> + ,invoke_case<false, int, foo> + ,invoke_case<false, void, foo*> + ,invoke_case<false, void, foo&> + ,invoke_case<true, void, foo&&> + ,invoke_case<false, int, foo&&> + ,invoke_case<false, void, std::reference_wrapper<foo>> + ,invoke_case<true, void, foo const> + ,invoke_case<false, int, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<true, void, foo const&&> + ,invoke_case<false, int, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + +#endif // #ifndef BOOST_CLBL_TRTS_MSVC + + run_tests<int + ,invoke_case<false, void, foo> + ,invoke_case<false, void, foo*> + ,invoke_case<false, void, foo&> + ,invoke_case<false, void, foo&&> + ,invoke_case<false, void, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + + auto f = [](int){}; + + run_tests<decltype(f) + ,invoke_case<true, void, int> + ,invoke_case<true, void, char> + ,invoke_case<false, int, int> + ,invoke_case<false, int, char> + ,invoke_case<false, void, void*> + >(); + + auto g = [](){}; + + run_tests<decltype(g) + ,invoke_case<true, void> + ,invoke_case<true, void> + ,invoke_case<false, void, int> + ,invoke_case<false, void, char> + ,invoke_case<false, int, int> + ,invoke_case<false, int, char> + ,invoke_case<false, void, void*> + >(); + +// libc++ requires constructible types be passed to std::is_invocable +#ifndef _LIBCPP_VERSION + + run_tests<void(int) + ,invoke_case<true, void, int> + ,invoke_case<true, void, char> + ,invoke_case<false, int, int> + ,invoke_case<false, int, char> + ,invoke_case<false, void, void*> + >(); + + run_tests<void() + ,invoke_case<false, void, int> + ,invoke_case<false, void, char> + ,invoke_case<false, void, void*> + >(); + + run_tests<void + ,invoke_case<false, void, foo> + ,invoke_case<false, void, foo*> + ,invoke_case<false, void, foo&> + ,invoke_case<false, void, foo&&> + ,invoke_case<false, void, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); +#endif + + run_tests<int + ,invoke_case<false, void, foo> + ,invoke_case<false, void, foo*> + ,invoke_case<false, void, foo&> + ,invoke_case<false, void, foo&&> + ,invoke_case<false, void, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, int> + >(); + + run_tests<void* + ,invoke_case<false, void, foo> + ,invoke_case<false, void, foo*> + ,invoke_case<false, void, foo&> + ,invoke_case<false, void, foo&&> + ,invoke_case<false, void, std::reference_wrapper<foo>> + ,invoke_case<false, void, foo const> + ,invoke_case<false, void, foo const*> + ,invoke_case<false, void, foo const&> + ,invoke_case<false, void, foo const&&> + ,invoke_case<false, void, std::reference_wrapper<foo const>> + ,invoke_case<false, void, foo, int> + ,invoke_case<false, void, foo*, int> + ,invoke_case<false, void, foo&, int> + ,invoke_case<false, void, foo&&, int> + ,invoke_case<false, void, std::reference_wrapper<foo>, 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 00000000..b18e6a6f --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_lvalue_reference_member.hpp> +#include "test.hpp" + + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +struct foo {}; + +template<typename T> +void assert_lvalue_qualified() { + + CT_ASSERT( is_lvalue_reference_member<T>()); +} + + +template<typename T> +void assert_not_lvalue_qualified() { + + CT_ASSERT(! is_lvalue_reference_member<T>()); +} + +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<f>(); + assert_lvalue_qualified<l>(); + assert_not_lvalue_qualified<r>(); + assert_not_lvalue_qualified<c>(); + assert_lvalue_qualified<cl>(); + assert_not_lvalue_qualified<cr>(); + assert_not_lvalue_qualified<v>(); + assert_lvalue_qualified<vl>(); + assert_not_lvalue_qualified<vr>(); + assert_not_lvalue_qualified<cv>(); + assert_lvalue_qualified<cvl>(); + assert_not_lvalue_qualified<cvr>(); + } + + { + 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<f>(); + assert_lvalue_qualified<l>(); + assert_not_lvalue_qualified<r>(); + assert_not_lvalue_qualified<c>(); + assert_lvalue_qualified<cl>(); + assert_not_lvalue_qualified<cr>(); + assert_not_lvalue_qualified<v>(); + assert_lvalue_qualified<vl>(); + assert_not_lvalue_qualified<vr>(); + assert_not_lvalue_qualified<cv>(); + assert_lvalue_qualified<cvl>(); + assert_not_lvalue_qualified<cvr>(); + } + + { + 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<f>()); + CT_ASSERT( is_lvalue_reference_member<l>()); + CT_ASSERT(! is_lvalue_reference_member<r>()); + CT_ASSERT(! is_lvalue_reference_member<c>()); + CT_ASSERT( is_lvalue_reference_member<cl>()); + CT_ASSERT(! is_lvalue_reference_member<cr>()); + CT_ASSERT(! is_lvalue_reference_member<v>()); + CT_ASSERT( is_lvalue_reference_member<vl>()); + CT_ASSERT(! is_lvalue_reference_member<vr>()); + CT_ASSERT(! is_lvalue_reference_member<cv>()); + CT_ASSERT( is_lvalue_reference_member<cvl>()); + CT_ASSERT(! is_lvalue_reference_member<cvr>()); + } + + using f_ptr = void(*)(); + assert_not_lvalue_qualified<f_ptr>(); + assert_not_lvalue_qualified<f_ptr foo::*>(); + assert_not_lvalue_qualified<int foo::*>(); + assert_not_lvalue_qualified<void(&)()>(); +} + +#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 00000000..e92129ee --- /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 <boost/callable_traits/detail/config.hpp> + +#include <boost/callable_traits/is_noexcept.hpp> +#include "test.hpp" + +template<typename Noexcept, typename NotNoexcept> +void test() { + + CT_ASSERT( is_noexcept<Noexcept>::value + // for old compilers, TEST_NOEXCEPT_QUAL is empty so types are same + || std::is_same<Noexcept, NotNoexcept>::value); + + CT_ASSERT(! is_noexcept<NotNoexcept>::value); +} + +#define TEST_NOEXCEPT(not_noexcept) test<not_noexcept BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER, not_noexcept>() + +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 00000000..6eaa2e9c --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_rvalue_reference_member.hpp> +#include "test.hpp" + + +#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS +int main(){ return 0; } +#else + +struct foo {}; + +template<typename T> +void assert_rvalue_qualified() { + + CT_ASSERT( is_rvalue_reference_member<T>()); +} + + +template<typename T> +void assert_not_rvalue_qualified() { + + CT_ASSERT(! is_rvalue_reference_member<T>()); +} + +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<f>(); + assert_not_rvalue_qualified<l>(); + assert_rvalue_qualified<r>(); + assert_not_rvalue_qualified<c>(); + assert_not_rvalue_qualified<cl>(); + assert_rvalue_qualified<cr>(); + assert_not_rvalue_qualified<v>(); + assert_not_rvalue_qualified<vl>(); + assert_rvalue_qualified<vr>(); + assert_not_rvalue_qualified<cv>(); + assert_not_rvalue_qualified<cvl>(); + assert_rvalue_qualified<cvr>(); + } + + { + 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<f>(); + assert_not_rvalue_qualified<l>(); + assert_rvalue_qualified<r>(); + assert_not_rvalue_qualified<c>(); + assert_not_rvalue_qualified<cl>(); + assert_rvalue_qualified<cr>(); + assert_not_rvalue_qualified<v>(); + assert_not_rvalue_qualified<vl>(); + assert_rvalue_qualified<vr>(); + assert_not_rvalue_qualified<cv>(); + assert_not_rvalue_qualified<cvl>(); + assert_rvalue_qualified<cvr>(); + } + + { + 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<f>()); + CT_ASSERT(! is_rvalue_reference_member<l>()); + CT_ASSERT( is_rvalue_reference_member<r>()); + CT_ASSERT(! is_rvalue_reference_member<c>()); + CT_ASSERT(! is_rvalue_reference_member<cl>()); + CT_ASSERT( is_rvalue_reference_member<cr>()); + CT_ASSERT(! is_rvalue_reference_member<v>()); + CT_ASSERT(! is_rvalue_reference_member<vl>()); + CT_ASSERT( is_rvalue_reference_member<vr>()); + CT_ASSERT(! is_rvalue_reference_member<cv>()); + CT_ASSERT(! is_rvalue_reference_member<cvl>()); + CT_ASSERT( is_rvalue_reference_member<cvr>()); + } + + using f_ptr = void(*)(); + assert_not_rvalue_qualified<f_ptr>(); + assert_not_rvalue_qualified<f_ptr foo::*>(); + assert_not_rvalue_qualified<int foo::*>(); + assert_not_rvalue_qualified<void(&)()>(); +} + +#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 00000000..e1cedd01 --- /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 <boost/callable_traits/is_transaction_safe.hpp> +#include "test.hpp" + +template<typename Safe, typename NotSafe> +void test() { + + CT_ASSERT( is_transaction_safe<Safe>::value + // for when tx safe is disabled + || std::is_same<Safe, NotSafe>::value); + CT_ASSERT(! is_transaction_safe<NotSafe>::value); +} + +#define TEST_TRANSACTION_SAFE(not_safe) \ + test<not_safe BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER, not_safe>() + +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 00000000..26522e84 --- /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 <type_traits> +#include <functional> +#include <utility> +#include <boost/callable_traits/is_volatile_member.hpp> +#include "test.hpp" + +struct foo {}; + +template<typename T> +void assert_volatile_qualified() { + CT_ASSERT( is_volatile_member<T>::value); +} + + +template<typename T> +void assert_not_volatile_qualified() { + CT_ASSERT(! is_volatile_member<T>::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<f>(); + assert_not_volatile_qualified<l>(); + assert_not_volatile_qualified<r>(); + assert_not_volatile_qualified<c>(); + assert_not_volatile_qualified<cl>(); + assert_not_volatile_qualified<cr>(); + assert_volatile_qualified<v>(); + assert_volatile_qualified<vl>(); + assert_volatile_qualified<vr>(); + assert_volatile_qualified<cv>(); + assert_volatile_qualified<cvl>(); + assert_volatile_qualified<cvr>(); + } + + { + 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<f>(); + assert_not_volatile_qualified<l>(); + assert_not_volatile_qualified<r>(); + assert_not_volatile_qualified<c>(); + assert_not_volatile_qualified<cl>(); + assert_not_volatile_qualified<cr>(); + assert_volatile_qualified<v>(); + assert_volatile_qualified<vl>(); + assert_volatile_qualified<vr>(); + assert_volatile_qualified<cv>(); + assert_volatile_qualified<cvl>(); + assert_volatile_qualified<cvr>(); + } + +#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<f>()); + CT_ASSERT(! is_volatile_member<l>()); + CT_ASSERT(! is_volatile_member<r>()); + CT_ASSERT(! is_volatile_member<c>()); + CT_ASSERT(! is_volatile_member<cl>()); + CT_ASSERT(! is_volatile_member<cr>()); + CT_ASSERT( is_volatile_member<v>()); + CT_ASSERT( is_volatile_member<vl>()); + CT_ASSERT( is_volatile_member<vr>()); + CT_ASSERT( is_volatile_member<cv>()); + CT_ASSERT( is_volatile_member<cvl>()); + CT_ASSERT( is_volatile_member<cvr>()); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + using f_ptr = void(*)(); + assert_not_volatile_qualified<f_ptr>(); + assert_not_volatile_qualified<f_ptr foo::*>(); + assert_not_volatile_qualified<int foo::*>(); + assert_not_volatile_qualified<void(&)()>(); +} 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 00000000..59a98510 --- /dev/null +++ b/src/boost/libs/callable_traits/test/qualified_class_of.cpp @@ -0,0 +1,52 @@ +#include <tuple> +#include <utility> +#include <type_traits> +#include <boost/callable_traits/qualified_class_of.hpp> +#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<test, expect>::value); + } + + { + using f = void(foo::*)() const; + using test = TRAIT(qualified_class_of, f); + using expect = foo const &; + CT_ASSERT(std::is_same<test, expect>::value); + } + + { + using f = void(foo::*)() volatile; + using test = TRAIT(qualified_class_of, f); + using expect = foo volatile &; + CT_ASSERT(std::is_same<test, expect>::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<test, expect>::value); + } + + { + using f = int foo::*; + using test = TRAIT(qualified_class_of, f); + using expect = foo const &; + CT_ASSERT(std::is_same<test, expect>::value); + } + + { + using f = const int foo::*; + using test = TRAIT(qualified_class_of, f); + using expect = foo const &; + CT_ASSERT(std::is_same<test, expect>::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 00000000..c86d5115 --- /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 <boost/callable_traits/qualified_class_of.hpp> +#include "test.hpp" + +template<typename T> +struct is_substitution_failure_qualified_class_of { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(qualified_class_of, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +struct foo; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_qualified_class_of<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<void>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<void*>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int &>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int(*)()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int(**)()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int(&)()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int (* const &)()>::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of<int (foo::* &)()>::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of<int (foo::* const)()>::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of<int (foo::* const &)()>::value); + CT_ASSERT(!is_substitution_failure_qualified_class_of<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int (foo::**)()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int (foo::* const *)()>::value); + CT_ASSERT(is_substitution_failure_qualified_class_of<int (foo::* volatile *)()>::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 00000000..ed01eaa1 --- /dev/null +++ b/src/boost/libs/callable_traits/test/qualifier_metafunction_constraints.cpp @@ -0,0 +1,48 @@ + +#include <boost/callable_traits.hpp> +#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 00000000..b3bf664c --- /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<typename T> +struct PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST) { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(CALLABLE_TRAIT_UNDER_TEST, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +bool PP_CAT(test_, CALLABLE_TRAIT_UNDER_TEST)() { + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int &>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int(&)()>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int(*)()>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int(* const foo::*)()>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int foo::*>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int (foo::* &)()>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int (foo::* const)()>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int (foo::* const &)()>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<int (foo::* volatile)()>::value); + + auto lambda = [](){}; + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<decltype(lambda)>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<decltype(lambda)&>::value); + CT_ASSERT(PP_CAT(is_sub_failure_, CALLABLE_TRAIT_UNDER_TEST)<void>::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 00000000..1c16f29e --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/remove_member_const.hpp> +#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<f, TRAIT(remove_member_const, f)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_const, c)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_const, l)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_const, cl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_const, r)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_const, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_const, v)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_const, cv)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_member_const, vl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_member_const, cvl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_member_const, vr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_member_const, cvr)>{}); + } + + { + 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<f, TRAIT(remove_member_const, f)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_const, c)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_const, l)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_const, cl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_const, r)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_const, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_const, v)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_const, cv)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_member_const, vl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_member_const, cvl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_member_const, vr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_member_const, cvr)>{}); + } + +#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<f, TRAIT(remove_member_const, f)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_const, c)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_const, l)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_const, cl)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_const, r)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_const, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_const, v)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_const, cv)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_member_const, vl)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_member_const, cvl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_member_const, vr)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_member_const, cvr)>{}); + } + +#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 00000000..67a8b6c7 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/remove_member_reference.hpp> +#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<f, TRAIT(remove_member_reference, f)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_reference, c)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_reference, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_member_reference, cv)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_reference, l)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_reference, cl)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_reference, vl)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_member_reference, cvl)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_reference, r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_reference, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_reference, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_member_reference, cvr)>{}); + } + + { + 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<f, TRAIT(remove_member_reference, f)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_reference, c)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_reference, v)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_member_reference, cv)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_reference, l)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_reference, cl)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_reference, vl)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_member_reference, cvl)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_reference, r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_reference, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_member_reference, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_member_reference, cvr)>{}); + } +} + +#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 00000000..79dcacd1 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/remove_member_volatile.hpp> +#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<f, TRAIT(remove_member_volatile, f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_volatile, vl)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_volatile, l)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_volatile, v)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_volatile, r)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_volatile, vr)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_volatile, c)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_volatile, cv)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_member_volatile, cl)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_member_volatile, cvl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_member_volatile, cr)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_member_volatile, cvr)>{}); + } + +#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<f, TRAIT(remove_member_volatile, f)>{}); + CT_ASSERT(std::is_same<f, TRAIT(remove_member_volatile, v)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_volatile, vl)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_member_volatile, l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_volatile, r)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_member_volatile, vr)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_volatile, c)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_member_volatile, cv)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_member_volatile, cl)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_member_volatile, cvl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_member_volatile, cr)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_member_volatile, cvr)>{}); + } + +#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 00000000..8cb8b148 --- /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 <boost/callable_traits/detail/config.hpp> +#include "test.hpp" + +#include <boost/callable_traits/remove_noexcept.hpp> + +template<typename Noexcept, typename NotNoexcept> +void test() { + + CT_ASSERT(std::is_same<NotNoexcept, TRAIT(remove_noexcept, Noexcept)>::value); +} + +#define TEST_NOEXCEPT(not_noexcept) \ + test<not_noexcept BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER, not_noexcept>() + +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 00000000..9df96a42 --- /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 <boost/callable_traits/remove_noexcept.hpp> +#include <tuple> +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES +int main(){} +#else + +template<typename T> +struct is_substitution_failure_remove_noexcept { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(remove_noexcept, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +struct foo; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_remove_noexcept<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int &>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int (* const &)()>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* &)()>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* const)()>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* const &)()>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<void>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<void*>::value); + CT_ASSERT(is_substitution_failure_remove_noexcept<void(**)()>::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 00000000..48104154 --- /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 <boost/callable_traits/remove_transaction_safe.hpp> + +template<typename Safe, typename NotSafe> +void test() { + + CT_ASSERT(std::is_same<NotSafe, TRAIT(remove_transaction_safe, Safe)>::value); + + //sanity check + #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE + CT_ASSERT(!std::is_same<Safe, NotSafe>::value); + #endif +} + +#define TEST_TRANSACTION_SAFE(not_safe) \ + test<not_safe BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER, not_safe>() + +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 00000000..0daadebe --- /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 <boost/callable_traits/remove_transaction_safe.hpp> +#include <tuple> +#include "test.hpp" + +#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE +int main(){} +#else + +template<typename T> +struct is_substitution_failure_remove_tx_safe { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(remove_transaction_safe, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +struct foo; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_remove_tx_safe<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int &>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int (* const &)()>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int (foo::* &)()>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int (foo::* const)()>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int (foo::* const &)()>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<void>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<void*>::value); + CT_ASSERT(is_substitution_failure_remove_tx_safe<void(**)()>::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 00000000..f5f91d6f --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <boost/callable_traits/remove_varargs.hpp> +#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<f, TRAIT(remove_varargs, va_f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_varargs, va_l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_varargs, va_r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_varargs, va_c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_varargs, va_cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_varargs, va_cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_varargs, va_v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_varargs, va_vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_varargs, va_vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_varargs, va_cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(remove_varargs, va_cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(remove_varargs, va_cvr)>{}); + + CT_ASSERT(std::is_same<f, TRAIT(remove_varargs, f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_varargs, l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_varargs, r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_varargs, c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_varargs, cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_varargs, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_varargs, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_varargs, vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_varargs, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_varargs, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(remove_varargs, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(remove_varargs, cvr)>{}); + } + + { + 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<f, TRAIT(remove_varargs, va_f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_varargs, va_l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_varargs, va_r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_varargs, va_c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_varargs, va_cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_varargs, va_cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_varargs, va_v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_varargs, va_vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_varargs, va_vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_varargs, va_cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(remove_varargs, va_cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(remove_varargs, va_cvr)>{}); + + CT_ASSERT(std::is_same<f, TRAIT(remove_varargs, f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_varargs, l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_varargs, r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_varargs, c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_varargs, cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_varargs, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_varargs, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_varargs, vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_varargs, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_varargs, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(remove_varargs, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(remove_varargs, cvr)>{}); + } + +#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<f, TRAIT(remove_varargs, va_f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_varargs, va_l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_varargs, va_r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_varargs, va_c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_varargs, va_cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_varargs, va_cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_varargs, va_v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_varargs, va_vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_varargs, va_vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_varargs, va_cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(remove_varargs, va_cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(remove_varargs, va_cvr)>{}); + + CT_ASSERT(std::is_same<f, TRAIT(remove_varargs, f)>{}); + CT_ASSERT(std::is_same<l, TRAIT(remove_varargs, l)>{}); + CT_ASSERT(std::is_same<r, TRAIT(remove_varargs, r)>{}); + CT_ASSERT(std::is_same<c, TRAIT(remove_varargs, c)>{}); + CT_ASSERT(std::is_same<cl, TRAIT(remove_varargs, cl)>{}); + CT_ASSERT(std::is_same<cr, TRAIT(remove_varargs, cr)>{}); + CT_ASSERT(std::is_same<v, TRAIT(remove_varargs, v)>{}); + CT_ASSERT(std::is_same<vl, TRAIT(remove_varargs, vl)>{}); + CT_ASSERT(std::is_same<vr, TRAIT(remove_varargs, vr)>{}); + CT_ASSERT(std::is_same<cv, TRAIT(remove_varargs, cv)>{}); + CT_ASSERT(std::is_same<cvl, TRAIT(remove_varargs, cvl)>{}); + CT_ASSERT(std::is_same<cvr, TRAIT(remove_varargs, cvr)>{}); + } + +#endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS + + { + using f = void(&)(); + using va_f = void(&)(...); + CT_ASSERT(std::is_same<f, TRAIT(remove_varargs, va_f)>{}); + } +} 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 00000000..d891fba5 --- /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 <boost/callable_traits/remove_varargs.hpp> +#include <tuple> +#include "test.hpp" + +struct foo; + +template<typename T> +struct is_substitution_failure_remove_varargs { + + template<typename> + static auto test(...) -> std::true_type; + + template<typename A, + typename std::remove_reference< + TRAIT(add_varargs, A)>::type* = nullptr> + static auto test(int) -> std::false_type; + + static constexpr bool value = decltype(test<T>(0))::value; +}; + +int main() { + + auto lambda = [](){}; + + CT_ASSERT(is_substitution_failure_remove_varargs<decltype(lambda)>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<decltype(lambda)&>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int &>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int (* const &)()>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int (foo::* &)()>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int (foo::* const)()>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int (foo::* const &)()>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<int (foo::* volatile)()>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<void>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<void*>::value); + CT_ASSERT(is_substitution_failure_remove_varargs<void(**)()>::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 00000000..11362c07 --- /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 <type_traits> +#include <cstdint> +#include <memory> +#include <boost/callable_traits.hpp> +#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<pmf>, int>{}); + } { + using pmf = decltype(&foo2::bar); + CT_ASSERT(std::is_same< return_type_t<pmf>, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t<foo3>, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t<foo4>, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t<decltype(foo5)>, int>{}); + } { + CT_ASSERT(std::is_same< return_type_t<decltype(foo6)>, 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 00000000..58266c95 --- /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 <type_traits> +#include <functional> +#include <tuple> +#include <utility> +#include <boost/callable_traits.hpp> + +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<typename T1, typename T2> +void assert_same() { + CT_ASSERT(std::is_same<T1, T2>::value); +} |