mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
removing callable_traits
* replacing callable_traits with private implementation
This commit is contained in:
parent
c8b8c4d502
commit
4c1caf3462
@ -45,9 +45,10 @@ install:
|
||||
test_script:
|
||||
- cmd: ..\..\b2 %B2_OPTS% cxxstd=latest test//minimal test//serialization
|
||||
- sh:
|
||||
../../b2 $B2_OPTS cxxstd=14 exception-handling=off rtti=off test//minimal &&
|
||||
../../b2 $B2_OPTS toolset=gcc-9 cxxstd=latest examples test//all &&
|
||||
../../b2 $B2_OPTS toolset=clang cxxstd=latest variant=histogram_ubasan test//all
|
||||
B2="../../b2 ${B2_OPTS}";
|
||||
$B2 toolset=gcc-7 cxxstd=14 exception-handling=off rtti=off test//minimal &&
|
||||
$B2 toolset=gcc-9 cxxstd=latest examples test//all &&
|
||||
$B2 toolset=clang-6 cxxstd=latest variant=histogram_ubasan test//all
|
||||
|
||||
## Uncomment the following to stop VM and enable interactive login.
|
||||
## Instructions how to log into the Appveyor VM are automatically printed.
|
||||
|
@ -46,7 +46,7 @@ matrix:
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
- cd libs/histogram
|
||||
- B2="../../b2 -q -j2 warnings-as-errors=on"
|
||||
- B2="../../b2 -q -j2 warnings-as-errors=on"
|
||||
script:
|
||||
$B2 cxxstd=latest exception-handling=off test//minimal &&
|
||||
$B2 cxxstd=latest test//all
|
||||
@ -79,10 +79,10 @@ matrix:
|
||||
- pip install cpp-coveralls
|
||||
script:
|
||||
# don't compile examples in coverage build, coverage must come from tests alone
|
||||
$B2 toolset=gcc-5 cxxstd=14 examples test//all &&
|
||||
$B2 toolset=gcc-5 cxxstd=14 exception-handling=off rtti=off test//minimal &&
|
||||
$B2 toolset=gcc-5 cxxstd=14 test//all examples &&
|
||||
$B2 toolset=gcc-8 cxxstd=latest coverage=on test//all &&
|
||||
GCOV=gcov-8 tools/cov.sh
|
||||
|
||||
GCOV=gcov-8 tools/cov.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright Peter Dimov, Hans Dembinski 2018-2019
|
||||
# Copyright Peter Dimov, Hans Dembinski 2018-2019
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
@ -23,7 +23,6 @@ target_include_directories(boost_histogram
|
||||
target_link_libraries(boost_histogram
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::callable_traits
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::mp11
|
||||
@ -56,7 +55,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
fetch_and_include(cmake/boost_fetch.cmake)
|
||||
|
||||
boost_fetch(boostorg/assert TAG develop)
|
||||
boost_fetch(hdembinski/callable_traits TAG origin/fix_cmake)
|
||||
boost_fetch(boostorg/config TAG develop)
|
||||
boost_fetch(boostorg/core TAG develop)
|
||||
boost_fetch(boostorg/mp11 TAG develop)
|
||||
@ -98,11 +96,11 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
#
|
||||
# install(TARGETS boost_histogram
|
||||
# boost_assert
|
||||
# boost_callable_traits
|
||||
# boost_config
|
||||
# boost_core
|
||||
# boost_mp11
|
||||
# boost_throw_exception
|
||||
# boost_variant2
|
||||
# EXPORT ${PROJECT_NAME}Targets)
|
||||
# install(EXPORT ${PROJECT_NAME}Targets
|
||||
# DESTINATION ${CONFIG_INSTALL_DIR}
|
||||
|
@ -7,27 +7,51 @@
|
||||
#ifndef BOOST_HISTOGRAM_DETAIL_ARGS_TYPE_HPP
|
||||
#define BOOST_HISTOGRAM_DETAIL_ARGS_TYPE_HPP
|
||||
|
||||
#include <boost/config/workaround.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, >= 65000)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
||||
#endif
|
||||
#include <boost/callable_traits/args.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, >= 65000)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#include <boost/mp11/list.hpp> // mp_pop_front
|
||||
#include <boost/mp11/utility.hpp> // mp_if
|
||||
#include <tuple>
|
||||
#include <type_traits> // is_member_function_pointer
|
||||
|
||||
namespace boost {
|
||||
namespace histogram {
|
||||
namespace detail {
|
||||
|
||||
template <class T, class Args = callable_traits::args_t<T>>
|
||||
using args_type =
|
||||
mp11::mp_if<std::is_member_function_pointer<T>, mp11::mp_pop_front<Args>, Args>;
|
||||
template <class T>
|
||||
struct args_type_impl {
|
||||
using T::ERROR_this_should_never_be_instantiated_please_write_an_issue;
|
||||
};
|
||||
|
||||
template <class R, class T, class... Ts>
|
||||
struct args_type_impl<R (T::*)(Ts...)> {
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
|
||||
template <class R, class T, class... Ts>
|
||||
struct args_type_impl<R (T ::*)(Ts...) const> {
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
|
||||
template <class R, class... Ts>
|
||||
struct args_type_impl<R (*)(Ts...)> {
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
|
||||
#if __cpp_noexcept_function_type >= 201510
|
||||
template <class R, class T, class... Ts>
|
||||
struct args_type_impl<R (T::*)(Ts...) noexcept> {
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
|
||||
template <class R, class T, class... Ts>
|
||||
struct args_type_impl<R (T ::*)(Ts...) const noexcept> {
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
|
||||
template <class R, class... Ts>
|
||||
struct args_type_impl<R (*)(Ts...) noexcept> {
|
||||
using type = std::tuple<Ts...>;
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class FunctionPointer>
|
||||
using args_type = typename args_type_impl<FunctionPointer>::type;
|
||||
|
||||
template <class T, std::size_t N = 0>
|
||||
using arg_type = std::tuple_element_t<N, args_type<T>>;
|
||||
|
@ -4,24 +4,28 @@
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/histogram/detail/args_type.hpp>
|
||||
#include <tuple>
|
||||
#include "std_ostream.hpp"
|
||||
|
||||
using namespace boost::histogram::detail;
|
||||
namespace dtl = boost::histogram::detail;
|
||||
|
||||
struct Foo {
|
||||
static int f1(char);
|
||||
int f1(char);
|
||||
int f2(long) const;
|
||||
static int f3(char, int);
|
||||
auto f4(char, int) { return 0; };
|
||||
};
|
||||
|
||||
int main() {
|
||||
BOOST_TEST_TRAIT_SAME(args_type<decltype(&Foo::f1)>, std::tuple<char>);
|
||||
BOOST_TEST_TRAIT_SAME(args_type<decltype(&Foo::f2)>, std::tuple<long>);
|
||||
BOOST_TEST_TRAIT_SAME(arg_type<decltype(&Foo::f1)>, char);
|
||||
BOOST_TEST_TRAIT_SAME(arg_type<decltype(&Foo::f2)>, long);
|
||||
BOOST_TEST_TRAIT_SAME(dtl::args_type<decltype(&Foo::f1)>, std::tuple<char>);
|
||||
BOOST_TEST_TRAIT_SAME(dtl::args_type<decltype(&Foo::f2)>, std::tuple<long>);
|
||||
BOOST_TEST_TRAIT_SAME(dtl::args_type<decltype(&Foo::f3)>, std::tuple<char, int>);
|
||||
BOOST_TEST_TRAIT_SAME(dtl::args_type<decltype(&Foo::f4)>, std::tuple<char, int>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(dtl::arg_type<decltype(&Foo::f3)>, char);
|
||||
BOOST_TEST_TRAIT_SAME(dtl::arg_type<decltype(&Foo::f3), 1>, int);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user