diff --git a/turtle/detail/function_impl_template.hpp b/turtle/detail/function_impl_template.hpp index bede0c8..68c8259 100644 --- a/turtle/detail/function_impl_template.hpp +++ b/turtle/detail/function_impl_template.hpp @@ -127,6 +127,17 @@ namespace detail return error_type::abort(); } + void add( context& c, const void* p, + boost::unit_test::const_string instance, + boost::optional< type_name > type, + boost::unit_test::const_string name ) + { + if( ! context_ ) + c.add( *this ); + c.add( p, *this, instance, type, name ); + context_ = &c; + } + friend std::ostream& operator<<( std::ostream& s, const function_impl& impl ) { diff --git a/turtle/detail/function_template.hpp b/turtle/detail/function_template.hpp index 1b59ee3..bbab134 100644 --- a/turtle/detail/function_template.hpp +++ b/turtle/detail/function_template.hpp @@ -89,10 +89,7 @@ namespace detail function& operator()( context& c, boost::unit_test::const_string instance ) { - if( ! impl_->context_ ) - c.add( *impl_ ); - c.add( impl_.get(), *impl_, instance, boost::none, "" ); - impl_->context_ = &c; + impl_->add( c, impl_.get(), instance, boost::none, "" ); return *this; } @@ -101,10 +98,7 @@ namespace detail boost::optional< type_name > type, boost::unit_test::const_string name ) const { - if( ! impl_->context_ ) - c.add( *impl_ ); - c.add( p, *impl_, instance, type, name ); - impl_->context_ = &c; + impl_->add( c, p, instance, type, name ); } private: