Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:44:12

0001 #ifndef BOOST_BIND_PROTECT_HPP_INCLUDED
0002 #define BOOST_BIND_PROTECT_HPP_INCLUDED
0003 
0004 //
0005 // protect.hpp
0006 //
0007 // Copyright 2002, 2020 Peter Dimov
0008 // Copyright 2009 Steven Watanabe
0009 //
0010 // Distributed under the Boost Software License, Version 1.0. (See
0011 // accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
0013 //
0014 
0015 #include <utility>
0016 
0017 namespace boost
0018 {
0019 
0020 namespace _bi
0021 {
0022 
0023 template<class T> struct protect_make_void
0024 {
0025     typedef void type;
0026 };
0027 
0028 template<class F, class E = void> struct protect_result_type
0029 {
0030 };
0031 
0032 template<class F> struct protect_result_type< F, typename protect_make_void<typename F::result_type>::type >
0033 {
0034     typedef typename F::result_type result_type;
0035 };
0036 
0037 template<class F> class protected_bind_t: public protect_result_type<F>
0038 {
0039 private:
0040 
0041     F f_;
0042 
0043 public:
0044 
0045     explicit protected_bind_t( F f ): f_( f )
0046     {
0047     }
0048 
0049     template<class... A> auto operator()( A&&... a ) -> decltype( f_( std::forward<A>(a)... ) )
0050     {
0051         return f_( std::forward<A>(a)... );
0052     }
0053 
0054     template<class... A> auto operator()( A&&... a ) const -> decltype( f_( std::forward<A>(a)... ) )
0055     {
0056         return f_( std::forward<A>(a)... );
0057     }
0058 };
0059 
0060 } // namespace _bi
0061 
0062 template<class F> _bi::protected_bind_t<F> protect(F f)
0063 {
0064     return _bi::protected_bind_t<F>(f);
0065 }
0066 
0067 } // namespace boost
0068 
0069 #endif // #ifndef BOOST_BIND_PROTECT_HPP_INCLUDED