summaryrefslogtreecommitdiff
path: root/boost/functional/lightweight_forward_adapter.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:41:18 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:43:11 +0900
commitf763a99a501650eff2c60288aa6f10ef916d769e (patch)
tree02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/functional/lightweight_forward_adapter.hpp
parent5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff)
downloadboost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz
boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2
boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/functional/lightweight_forward_adapter.hpp')
-rw-r--r--boost/functional/lightweight_forward_adapter.hpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/boost/functional/lightweight_forward_adapter.hpp b/boost/functional/lightweight_forward_adapter.hpp
index 637aa9e19c..2706d299dd 100644
--- a/boost/functional/lightweight_forward_adapter.hpp
+++ b/boost/functional/lightweight_forward_adapter.hpp
@@ -149,8 +149,31 @@ namespace boost
: boost::result_of< BOOST_DEDUCED_TYPENAME c<Self>::t() >
{ };
- template< class MD, class F, class FC >
- struct lightweight_forward_adapter_impl<MD,F,FC,0,0>
+ // When operator() doesn't have any parameters, it can't
+ // be templatized and can't use SFINAE, so intead use class
+ // template parameter SFINAE to decide whether to instantiate it.
+
+ template <typename T, typename R = void>
+ struct lightweight_forward_adapter_sfinae
+ {
+ typedef T type;
+ };
+
+ // This is the fallback for when there isn't an operator()(),
+ // need to create an operator() that will never instantiate
+ // so that using parent::operator() will work okay.
+ template< class MD, class F, class FC, class Enable = void>
+ struct lightweight_forward_adapter_impl_zero
+ : lightweight_forward_adapter_result
+ {
+ template <typename T> struct never_instantiate {};
+ template <typename T>
+ typename never_instantiate<T>::type operator()(T) const {}
+ };
+
+ template< class MD, class F, class FC>
+ struct lightweight_forward_adapter_impl_zero<MD, F, FC,
+ typename lightweight_forward_adapter_sfinae<typename boost::result_of< FC() >::type>::type>
: lightweight_forward_adapter_result
{
inline typename boost::result_of< FC() >::type
@@ -166,6 +189,12 @@ namespace boost
}
};
+ template< class MD, class F, class FC >
+ struct lightweight_forward_adapter_impl<MD,F,FC,0,0>
+ : lightweight_forward_adapter_impl_zero<MD,F,FC>
+ {
+ };
+
# define BOOST_PP_FILENAME_1 \
<boost/functional/lightweight_forward_adapter.hpp>
# define BOOST_PP_ITERATION_LIMITS \