/* Copyright 2017 Joaquin M Lopez Munoz. * 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) * * See http://www.boost.org/libs/poly_collection for library home page. */ #ifndef BOOST_TT_DETAIL_IS_LIKELY_STATELESS_LAMBDA_HPP #define BOOST_TT_DETAIL_IS_LIKELY_STATELESS_LAMBDA_HPP #if defined(_MSC_VER) #pragma once #endif #include #include #if defined(BOOST_TT_HAS_ACCURATE_BINARY_OPERATOR_DETECTION) // // We don't need or use this, just define a dummy class: // namespace boost{ namespace type_traits_detail{ template struct is_likely_stateless_lambda : public false_type {}; }} #elif !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !BOOST_WORKAROUND(BOOST_MSVC, < 1900) #include #include namespace boost{ namespace type_traits_detail{ /* Stateless lambda expressions have one (and only one) call operator and are * convertible to a function pointer with the same signature. Non-lambda types * could satisfy this too, hence the "likely" qualifier. */ template struct has_one_operator_call_helper { template static boost::true_type test(decltype(&Q::operator())*); template static boost::false_type test(...); using type=decltype(test(nullptr)); }; template using has_one_operator_call=typename has_one_operator_call_helper::type; template struct equivalent_function_pointer { template static auto helper(R (Q::*)(Args...)const)->R(*)(Args...); template static auto helper(R (Q::*)(Args...))->R(*)(Args...); using type=decltype(helper(&T::operator())); }; template struct is_likely_stateless_lambda : false_type{}; template struct is_likely_stateless_lambda< T, typename boost::enable_if_c::value>::type> : boost::is_convertible::type >{}; } /* namespace type_traits_detail */ } /* namespace boost */ #else // // Can't implement this: // namespace boost { namespace type_traits_detail { template struct is_likely_stateless_lambda : public boost::integral_constant {}; }} #endif #endif