forked from boostorg/bind
Update protect.hpp to use perfect forwarding on C++11
This commit is contained in:
@ -2,10 +2,10 @@
|
|||||||
#define BOOST_BIND_PROTECT_HPP_INCLUDED
|
#define BOOST_BIND_PROTECT_HPP_INCLUDED
|
||||||
|
|
||||||
//
|
//
|
||||||
// protect.hpp
|
// protect.hpp
|
||||||
//
|
//
|
||||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
// Copyright 2002, 2020 Peter Dimov
|
||||||
// Copyright (c) 2009 Steven Watanabe
|
// Copyright 2009 Steven Watanabe
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -13,7 +13,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -21,8 +22,41 @@ namespace boost
|
|||||||
namespace _bi
|
namespace _bi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||||
|
|
||||||
template<class F> class protected_bind_t
|
template<class F> class protected_bind_t
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
F f_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename F::result_type result_type;
|
||||||
|
|
||||||
|
explicit protected_bind_t( F f ): f_( f )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class... A> auto operator()( A&&... a ) -> decltype( f_( std::forward<A>(a)... ) )
|
||||||
|
{
|
||||||
|
return f_( std::forward<A>(a)... );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class... A> auto operator()( A&&... a ) const -> decltype( f_( std::forward<A>(a)... ) )
|
||||||
|
{
|
||||||
|
return f_( std::forward<A>(a)... );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<class F> class protected_bind_t
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
F f_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename F::result_type result_type;
|
typedef typename F::result_type result_type;
|
||||||
@ -286,12 +320,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
F f_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace _bi
|
} // namespace _bi
|
||||||
|
|
||||||
template<class F> _bi::protected_bind_t<F> protect(F f)
|
template<class F> _bi::protected_bind_t<F> protect(F f)
|
||||||
|
Reference in New Issue
Block a user