Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84986 - sandbox/container_gen/boost/utility
From: sponage_at_[hidden]
Date: 2013-07-09 01:45:35


Author: expaler
Date: 2013-07-09 01:45:35 EDT (Tue, 09 Jul 2013)
New Revision: 84986
URL: http://svn.boost.org/trac/boost/changeset/84986

Log:
Boost.ContainerGen: fixed bugs in equivalence_function, get_iterator_second, and get_iterator_value_second utilities.

Replaced:
   sandbox/container_gen/boost/utility/equivalence_function.hpp (contents, props changed)
   sandbox/container_gen/boost/utility/get_iterator_second.hpp (contents, props changed)
   sandbox/container_gen/boost/utility/get_iterator_value_second.hpp (contents, props changed)

Added: sandbox/container_gen/boost/utility/equivalence_function.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ sandbox/container_gen/boost/utility/equivalence_function.hpp 2013-07-09 01:45:35 EDT (Tue, 09 Jul 2013) (r84986)
@@ -0,0 +1,174 @@
+// Copyright (C) 2013 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_UTILITY_EQUIVALENCE_FUNCTION_HPP_INCLUDED
+#define BOOST_UTILITY_EQUIVALENCE_FUNCTION_HPP_INCLUDED
+
+namespace boost { namespace detail {
+
+ template <typename StrictWeakOrdering>
+ class adaptable_equivalence_function
+ {
+ StrictWeakOrdering _predicate;
+
+ public:
+ typedef bool
+ result_type;
+ typedef typename StrictWeakOrdering::first_argument_type
+ first_argument_type;
+ typedef typename StrictWeakOrdering::second_argument_type
+ second_argument_type;
+
+ adaptable_equivalence_function();
+
+ template <typename Predicate>
+ adaptable_equivalence_function(Predicate const& predicate);
+
+ result_type
+ operator()(
+ first_argument_type const& arg1
+ , second_argument_type const& arg2
+ ) const;
+ };
+
+ template <typename StrictWeakOrdering>
+ adaptable_equivalence_function<
+ StrictWeakOrdering
+ >::adaptable_equivalence_function() : _predicate()
+ {
+ }
+
+ template <typename StrictWeakOrdering>
+ template <typename Predicate>
+ adaptable_equivalence_function<
+ StrictWeakOrdering
+ >::adaptable_equivalence_function(Predicate const& predicate)
+ : _predicate(predicate)
+ {
+ }
+
+ template <typename StrictWeakOrdering>
+ inline typename adaptable_equivalence_function<
+ StrictWeakOrdering
+ >::result_type
+ adaptable_equivalence_function<StrictWeakOrdering>::operator()(
+ first_argument_type const& arg1
+ , second_argument_type const& arg2
+ ) const
+ {
+ return !this->_predicate(arg1, arg2) && !this->_predicate(arg2, arg1);
+ }
+
+ template <typename StrictWeakOrdering>
+ class plain_equivalence_function
+ {
+ StrictWeakOrdering _predicate;
+
+ public:
+ typedef bool result_type;
+
+ plain_equivalence_function();
+
+ template <typename Predicate>
+ plain_equivalence_function(Predicate const& predicate);
+
+ template <typename T1, typename T2>
+ result_type operator()(T1 const& t1, T2 const& t2) const;
+ };
+
+ template <typename StrictWeakOrdering>
+ plain_equivalence_function<
+ StrictWeakOrdering
+ >::plain_equivalence_function() : _predicate()
+ {
+ }
+
+ template <typename StrictWeakOrdering>
+ template <typename Predicate>
+ plain_equivalence_function<StrictWeakOrdering>::plain_equivalence_function(
+ Predicate const& predicate
+ ) : _predicate(predicate)
+ {
+ }
+
+ template <typename StrictWeakOrdering>
+ template <typename T1, typename T2>
+ inline typename plain_equivalence_function<StrictWeakOrdering>::result_type
+ plain_equivalence_function<StrictWeakOrdering>::operator()(
+ T1 const& t1
+ , T2 const& t2
+ ) const
+ {
+ return !this->_predicate(t1, t2) && !this->_predicate(t2, t1);
+ }
+}} // namespace boost::detail
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/detail/metafunction/is_adaptable_binary_func.hpp>
+#include <boost/detail/metafunction/is_function_wrt.hpp>
+
+//[reference__equivalence_function_gen
+namespace boost {
+
+ template <typename StrictWeakOrdering>
+ struct equivalence_function_gen
+ //<-
+ : ::boost::mpl::if_<
+ typename ::boost::mpl::if_<
+ ::boost::detail::metafunction::is_function_with_result_type<
+ StrictWeakOrdering
+ , bool
+ >
+ , ::boost::detail::metafunction::is_adaptable_binary_function<
+ StrictWeakOrdering
+ >
+ , ::boost::mpl::false_
+ >::type
+ , detail::adaptable_equivalence_function<StrictWeakOrdering>
+ , detail::plain_equivalence_function<StrictWeakOrdering>
+ >
+ //->
+ {
+//<-
+#if 0
+//->
+ typedef ... type;
+ //<-
+#endif
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 1
+ , equivalence_function_gen
+ , (StrictWeakOrdering)
+ )
+ //->
+ };
+} // namespace boost
+//]
+
+//[reference__make_equivalence_function
+namespace boost {
+
+ template <typename StrictWeakOrdering>
+ typename equivalence_function_gen<StrictWeakOrdering>::type
+ make_equivalence_function(StrictWeakOrdering const& predicate);
+} // namespace boost
+//]
+
+namespace boost {
+
+ template <typename StrictWeakOrdering>
+ inline typename equivalence_function_gen<StrictWeakOrdering>::type
+ make_equivalence_function(StrictWeakOrdering const& predicate)
+ {
+ return typename equivalence_function_gen<StrictWeakOrdering>::type(
+ predicate
+ );
+ }
+} // namespace boost
+
+#endif // BOOST_UTILITY_EQUIVALENCE_FUNCTION_HPP_INCLUDED
+

Added: sandbox/container_gen/boost/utility/get_iterator_second.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ sandbox/container_gen/boost/utility/get_iterator_second.hpp 2013-07-09 01:45:35 EDT (Tue, 09 Jul 2013) (r84986)
@@ -0,0 +1,120 @@
+// Copyright (C) 2012-2013 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_UTILITY_GET_ITERATOR_SECOND_HPP_INCLUDED
+#define BOOST_UTILITY_GET_ITERATOR_SECOND_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/boost/ref.hpp>
+#include <boost/ptr_container/detail/map_iterator.hpp>
+
+//[reference__get_iterator_second_result
+namespace boost {
+
+ template <typename Iterator>
+ struct get_iterator_second_result
+ {
+ typedef typename ::std::tr1::remove_pointer<
+ typename ::boost::unwrap_reference<
+ BOOST_TYPEOF_TPL(::boost::ref(Iterator()->second))
+ >::type
+ >::type&
+ type;
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1, get_iterator_second_result, (Iterator))
+ //->
+ };
+} // namespace boost
+//]
+
+namespace boost { namespace detail {
+
+ template <typename Iterator>
+ struct get_iterator_second_helper
+ {
+ typedef Iterator
+ argument_type;
+ typedef typename get_iterator_second_result<Iterator>::type
+ result_type;
+
+ result_type operator()(argument_type itr) const;
+
+ private:
+ static result_type _evaluate(Iterator itr, ::boost::mpl::true_);
+
+ static result_type _evaluate(Iterator itr, ::boost::mpl::false_);
+ };
+
+ template <typename Iterator>
+ inline typename get_iterator_second_helper<Iterator>::result_type
+ get_iterator_second_helper<Iterator>::_evaluate(
+ Iterator itr
+ , ::boost::mpl::true_
+ )
+ {
+ return *itr->second;
+ }
+
+ template <typename Iterator>
+ inline typename get_iterator_second_helper<Iterator>::result_type
+ get_iterator_second_helper<Iterator>::_evaluate(
+ Iterator itr
+ , ::boost::mpl::false_
+ )
+ {
+ return itr->second;
+ }
+
+ template <typename Iterator>
+ inline typename get_iterator_second_helper<Iterator>::result_type
+ get_iterator_second_helper<Iterator>::operator()(
+ argument_type itr
+ ) const
+ {
+ typedef typename ::boost::iterator_value<Iterator>::type _value_type;
+
+ return get_iterator_second_helper<Iterator>::_evaluate(
+ itr
+ , typename ::boost::mpl::if_<
+ ::std::tr1::is_same<
+ ::boost::ptr_container_detail::ref_pair<
+ typename _value_type::first_type
+ , typename _value_type::second_type
+ >
+ , _value_type
+ >
+ , ::boost::mpl::true_
+ , ::boost::mpl::false_
+ >::type()
+ );
+ }
+}} // namespace boost::detail
+
+//[reference__get_iterator_second
+namespace boost {
+
+ template <typename Iterator>
+ typename get_iterator_second_result<Iterator>::type
+ get_iterator_second(Iterator itr);
+} // namespace boost
+//]
+
+namespace boost {
+
+ template <typename Iterator>
+ inline typename get_iterator_second_result<Iterator>::type
+ get_iterator_second(Iterator itr)
+ {
+ return detail::get_iterator_second_helper<Iterator>()(itr);
+ }
+} // namespace boost
+
+#endif // BOOST_UTILITY_GET_ITERATOR_SECOND_HPP_INCLUDED
+

Added: sandbox/container_gen/boost/utility/get_iterator_value_second.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ sandbox/container_gen/boost/utility/get_iterator_value_second.hpp 2013-07-09 01:45:35 EDT (Tue, 09 Jul 2013) (r84986)
@@ -0,0 +1,130 @@
+// Copyright (C) 2012-2013 Cromwell D. Enage
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_UTILITY_GET_ITERATOR_VALUE_SECOND_HPP_INCLUDED
+#define BOOST_UTILITY_GET_ITERATOR_VALUE_SECOND_HPP_INCLUDED
+
+#include <boost/tr1/type_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/boost/ref.hpp>
+#include <boost/ptr_container/detail/map_iterator.hpp>
+#include <boost/utility/get_reference.hpp>
+
+//[reference__get_iterator_value_second_result
+namespace boost {
+
+ template <typename IterValue>
+ struct get_iterator_value_second_result
+ {
+ typedef typename ::std::tr1::remove_pointer<
+ typename ::boost::unwrap_reference<
+ BOOST_TYPEOF_TPL(
+ ::boost::ref(
+ ::boost::get_reference<
+ IterValue
+ >().second
+ )
+ )
+ >::type
+ >::type&
+ type;
+ //<-
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 1
+ , get_iterator_value_second_result
+ , (IterValue)
+ )
+ //->
+ };
+} // namespace boost
+//]
+
+namespace boost { namespace detail {
+
+ template <typename IterValue>
+ struct get_iterator_value_second_helper
+ {
+ typedef IterValue&
+ argument_type;
+ typedef typename get_iterator_value_second_result<IterValue>::type
+ result_type;
+
+ result_type operator()(argument_type itr) const;
+
+ private:
+ static result_type _evaluate(argument_type arg, ::boost::mpl::true_);
+
+ static result_type _evaluate(argument_type arg, ::boost::mpl::false_);
+ };
+
+ template <typename IterValue>
+ inline typename get_iterator_value_second_helper<IterValue>::result_type
+ get_iterator_value_second_helper<IterValue>::_evaluate(
+ argument_type arg
+ , ::boost::mpl::true_
+ )
+ {
+ return *arg.second;
+ }
+
+ template <typename IterValue>
+ inline typename get_iterator_value_second_helper<IterValue>::result_type
+ get_iterator_value_second_helper<IterValue>::_evaluate(
+ argument_type arg
+ , ::boost::mpl::false_
+ )
+ {
+ return arg.second;
+ }
+
+ template <typename IterValue>
+ inline typename get_iterator_value_second_helper<IterValue>::result_type
+ get_iterator_value_second_helper<IterValue>::operator()(
+ argument_type arg
+ ) const
+ {
+ typedef typename ::std::tr1::remove_const<IterValue>::type _value_type;
+
+ return get_iterator_value_second_helper<IterValue>::_evaluate(
+ arg
+ , typename ::boost::mpl::if_<
+ ::std::tr1::is_same<
+ ::boost::ptr_container_detail::ref_pair<
+ typename _value_type::first_type
+ , typename _value_type::second_type
+ >
+ , _value_type
+ >
+ , ::boost::mpl::true_
+ , ::boost::mpl::false_
+ >::type()
+ );
+ }
+}} // namespace boost::detail
+
+//[reference__get_iterator_value_second
+namespace boost {
+
+ template <typename IterValue>
+ typename get_iterator_value_second_result<IterValue>::type
+ get_iterator_value_second(IterValue& value);
+} // namespace boost
+//]
+
+namespace boost {
+
+ template <typename IterValue>
+ inline typename get_iterator_value_second_result<IterValue>::type
+ get_iterator_value_second(IterValue& value)
+ {
+ return detail::get_iterator_value_second_helper<IterValue>()(value);
+ }
+} // namespace boost
+
+#endif // BOOST_UTILITY_GET_ITERATOR_VALUE_SECOND_HPP_INCLUDED
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk