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
0006
0007
0008
0009
0010
0011
0012
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 }
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 }
0068
0069 #endif