mirror of
https://github.com/boostorg/callable_traits.git
synced 2026-02-10 11:22:13 +00:00
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
/*!<-
|
|
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 <callable_traits/is_constexpr.hpp>
|
|
#ifdef CALLABLE_TRAITS_DISABLE_CONSTEXPR_CHECKS
|
|
int main(){ return 0; }
|
|
#else
|
|
|
|
//[ is_constexpr_function_pointer
|
|
#include <type_traits>
|
|
#include <callable_traits/is_constexpr.hpp>
|
|
|
|
// NOTE: Due to non-compliance in MSVC, is_constexpr always
|
|
// returns std::false_type on that compiler, which causes
|
|
// the static asserts below to fail.
|
|
|
|
namespace ct = callable_traits;
|
|
|
|
constexpr int foo(const int&) {
|
|
return 1;
|
|
}
|
|
|
|
int bar(const int&) {
|
|
return 1;
|
|
}
|
|
|
|
// for is_constexpr calls, function pointers must
|
|
// be passed as std::integral_constants
|
|
using F = std::integral_constant<decltype(&foo), &foo>;
|
|
using B = std::integral_constant<decltype(&bar), &bar>;
|
|
|
|
static_assert(ct::is_constexpr(F{}), "");
|
|
static_assert(ct::is_constexpr<F>(), "");
|
|
static_assert(!ct::is_constexpr(B{}), "");
|
|
static_assert(!ct::is_constexpr<B>(), "");
|
|
|
|
int main() {}
|
|
//]
|
|
#endif
|