From eecd48b72ff2a6cd1e4be7fa596a2b3a7f659303 Mon Sep 17 00:00:00 2001 From: mat007 Date: Sat, 26 Apr 2014 07:06:00 +0000 Subject: [PATCH] Refactoring git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@717 860be788-9bd5-4423-9f1e-828f051e677b --- turtle/detail/function_impl_template.hpp | 11 +++++++++++ turtle/detail/function_template.hpp | 10 ++-------- 2 files changed, 13 insertions(+), 8 deletions(-) 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: