From 7c416b2ab19fb06b7d6b65424df528e7e27360d0 Mon Sep 17 00:00:00 2001 From: badair Date: Wed, 6 Apr 2016 18:55:24 -0500 Subject: [PATCH] tweaks regarding MSVC --- example/std_function/example.cpp | 2 +- .../detail/bind_expression.hpp | 8 ++-- test/can_invoke_constexpr.cpp | 14 ++---- test/is_constexpr.cpp | 48 ++++++++----------- 4 files changed, 30 insertions(+), 42 deletions(-) diff --git a/example/std_function/example.cpp b/example/std_function/example.cpp index 0e533e5..c1088a4 100644 --- a/example/std_function/example.cpp +++ b/example/std_function/example.cpp @@ -24,7 +24,7 @@ struct adder { } }; -void check_add(std::function f) { +void check_add(std::function& f) { auto add_result = f(99, 1); assert(add_result == 100); diff --git a/include/callable_traits/detail/bind_expression.hpp b/include/callable_traits/detail/bind_expression.hpp index fd21d74..0bdaeb2 100644 --- a/include/callable_traits/detail/bind_expression.hpp +++ b/include/callable_traits/detail/bind_expression.hpp @@ -157,12 +157,12 @@ namespace callable_traits { using return_type = typename traits::return_type; using result_type = return_type; - inline constexpr bind_type& + inline bind_type& get_std_bind() & { return std_bind; } - inline constexpr bind_type&& + inline bind_type&& get_std_bind() && { return std::move(std_bind); } @@ -174,12 +174,12 @@ namespace callable_traits { unwrap_std_bind(static_cast(args))...)) {} template - inline constexpr decltype(auto) + inline decltype(auto) operator()(Rgs&&... args) { return std_bind(std::forward(args)...); } - inline constexpr operator bind_type&() { + inline operator bind_type&() { return std_bind; } }; diff --git a/test/can_invoke_constexpr.cpp b/test/can_invoke_constexpr.cpp index 58c8473..08e7263 100644 --- a/test/can_invoke_constexpr.cpp +++ b/test/can_invoke_constexpr.cpp @@ -12,12 +12,6 @@ Distributed under the Boost Software License, Version 1.0. #define CT_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) #endif //CT_ASSERT -#ifdef CALLABLE_TRAITS_CONSTEXPR_CHECKS_DISABLED -#define IF_ENABLED ! -#else -#define IF_ENABLED -#endif - struct foo1 { int operator()() const { return 0; @@ -53,16 +47,16 @@ namespace ct = callable_traits; CT_ASSERT(!ct::can_invoke_constexpr(foo1{})); CT_ASSERT(!ct::can_invoke_constexpr(foo1{}, 0)); -CT_ASSERT(IF_ENABLED ct::can_invoke_constexpr(foo2{})); -CT_ASSERT(IF_ENABLED ct::can_invoke_constexpr(foo2{}, 0)); +CT_ASSERT( ct::can_invoke_constexpr(foo2{})); +CT_ASSERT( ct::can_invoke_constexpr(foo2{}, 0)); CT_ASSERT(!ct::can_invoke_constexpr(foo4{})); -CT_ASSERT(IF_ENABLED ct::can_invoke_constexpr(foo4{}, 0)); +CT_ASSERT( ct::can_invoke_constexpr(foo4{}, 0)); CT_ASSERT(!ct::can_invoke_constexpr(foo1_pmf{}, foo1{})); CT_ASSERT(!ct::can_invoke_constexpr(foo1_pmf{}, foo1{}, 0)); CT_ASSERT(!ct::can_invoke_constexpr(foo3_pmf{}, foo3{})); -CT_ASSERT(IF_ENABLED ct::can_invoke_constexpr(foo3_pmf{}, foo3{}, 0)); +CT_ASSERT( ct::can_invoke_constexpr(foo3_pmf{}, foo3{}, 0)); int main() { return 0; } diff --git a/test/is_constexpr.cpp b/test/is_constexpr.cpp index 988cbd5..d9276b6 100644 --- a/test/is_constexpr.cpp +++ b/test/is_constexpr.cpp @@ -12,12 +12,6 @@ Distributed under the Boost Software License, Version 1.0. #define CT_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) #endif //CT_ASSERT -#ifdef CALLABLE_TRAITS_CONSTEXPR_CHECKS_DISABLED -#define IF_ENABLED ! -#else -#define IF_ENABLED -#endif - namespace ct = callable_traits; namespace test1 { @@ -82,20 +76,20 @@ namespace test2 { constexpr int operator()(int, int, int, int, int, int, int, int, int, int) const & { return 1; } }; - CT_ASSERT(IF_ENABLED ct::is_constexpr(B1{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(B2{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(B3{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(B4{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(B5{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(B6{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(B7{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B1{})); + CT_ASSERT(ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B2{})); + CT_ASSERT(ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B3{})); + CT_ASSERT(ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B4{})); + CT_ASSERT(ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B5{})); + CT_ASSERT(ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B6{})); + CT_ASSERT(ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(B7{})); + CT_ASSERT(ct::is_constexpr()); } namespace test3 { @@ -105,16 +99,16 @@ namespace test3 { }; using C = std::integral_constant; - CT_ASSERT(IF_ENABLED ct::is_constexpr(C{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(C{})); + CT_ASSERT(ct::is_constexpr()); } namespace test4 { constexpr int foo(const int&) { return 1; } using D = std::integral_constant; - CT_ASSERT(IF_ENABLED ct::is_constexpr(D{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(D{})); + CT_ASSERT(ct::is_constexpr()); } namespace test5 { @@ -161,8 +155,8 @@ namespace test7 { CT_ASSERT(!ct::is_constexpr(G1{})); CT_ASSERT(!ct::is_constexpr()); - CT_ASSERT(IF_ENABLED ct::is_constexpr(G2{})); - CT_ASSERT(IF_ENABLED ct::is_constexpr()); + CT_ASSERT(ct::is_constexpr(G2{})); + CT_ASSERT(ct::is_constexpr()); // we can't resolve the overload in G3, due to the way // callable_traits::detail::any_arg_evaluated works @@ -170,4 +164,4 @@ namespace test7 { CT_ASSERT(!ct::is_constexpr()); } -int main() { return 0; } \ No newline at end of file +int main() { return 0; }