Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:21

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // times2_iterator.hpp
0003 //
0004 //  Copyright 2006 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006
0009 #define BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006
0010 
0011 #include <functional>
0012 #include <boost/detail/workaround.hpp>
0013 #include <boost/range/begin.hpp>
0014 #include <boost/range/end.hpp>
0015 #include <boost/range/iterator_range.hpp>
0016 #include <boost/iterator/transform_iterator.hpp>
0017 #include <boost/iterator/counting_iterator.hpp>
0018 #include <boost/iterator/permutation_iterator.hpp>
0019 
0020 namespace boost { namespace accumulators
0021 {
0022 
0023 namespace detail
0024 {
0025     typedef transform_iterator<
0026 #ifdef BOOST_NO_CXX98_BINDERS
0027         decltype(std::bind(std::multiplies<std::size_t>(), 2, std::placeholders::_1))
0028 #else
0029         std::binder1st<std::multiplies<std::size_t> >
0030 #endif
0031       , counting_iterator<std::size_t>
0032     > times2_iterator;
0033 
0034     inline times2_iterator make_times2_iterator(std::size_t i)
0035     {
0036         return make_transform_iterator(
0037             make_counting_iterator(i)
0038 #ifdef BOOST_NO_CXX98_BINDERS
0039           , std::bind(std::multiplies<std::size_t>(), 2, std::placeholders::_1)
0040 #else
0041           , std::bind1st(std::multiplies<std::size_t>(), 2)
0042 #endif
0043         );
0044     }
0045 
0046     ///////////////////////////////////////////////////////////////////////////////
0047     // lvalue_index_iterator
0048     template<typename Base>
0049     struct lvalue_index_iterator
0050       : Base
0051     {
0052         lvalue_index_iterator()
0053           : Base()
0054         {}
0055 
0056         lvalue_index_iterator(Base base)
0057           : Base(base)
0058         {
0059         }
0060 
0061         typename Base::reference operator [](typename Base::difference_type n) const
0062         {
0063             return *(*this + n);
0064         }
0065     };
0066 } // namespace detail
0067 
0068 }}
0069 
0070 #endif