From: g0dil Date: Thu, 8 Oct 2009 09:20:57 +0000 (+0000) Subject: Utils: Add senf::is_pair trait X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=5615d25d63a162a6aa3cde53448277da1842a223;p=senf.git Utils: Add senf::is_pair trait git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1479 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/type_traits.hh b/senf/Utils/type_traits.hh index f3e5811..910b4e4 100644 --- a/senf/Utils/type_traits.hh +++ b/senf/Utils/type_traits.hh @@ -260,6 +260,28 @@ namespace senf typename senf::remove_any_pointer::type>::arity> {}; + /** Test object if it is any \c std::pair type + + if \a Pair is any \c std::pair type, this trait will inherit from \c boost::true_type, + otherwise it will inherit from \c boost::false_type. + + \code + BOOST_STATIC_ASSERT(( senf::is_pair< std::pair >::value )); + BOOST_STATIC_ASSERT(( ! senf::is_pair< void () >::value )); + \endcode + */ + template + struct is_pair + : public boost::false_type + {}; + +#ifndef DOXYGEN + template + struct is_pair< std::pair > + : public boost::true_type + {}; +#endif + ///} #ifndef DOXYGEN diff --git a/senf/Utils/type_traits.test.cc b/senf/Utils/type_traits.test.cc index fb9fe5f..9b1c3ab 100644 --- a/senf/Utils/type_traits.test.cc +++ b/senf/Utils/type_traits.test.cc @@ -110,6 +110,11 @@ BOOST_AUTO_UNIT_TEST(typeTraits) BOOST_STATIC_ASSERT(( senf::function_arity::value == 2 )); BOOST_STATIC_ASSERT(( senf::function_arity::value == 0 )); BOOST_STATIC_ASSERT(( senf::function_arity::value == 2 )); + + BOOST_STATIC_ASSERT(( senf::function_arity::value == 1 )); + + BOOST_STATIC_ASSERT(( senf::is_pair< std::pair >::value )); + BOOST_STATIC_ASSERT(( ! senf::is_pair< void () >::value )); } ///////////////////////////////cc.e////////////////////////////////////////