annotate DEPENDENCIES/generic/include/boost/icl/concept/container.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*-----------------------------------------------------------------------------+
Chris@16 2 Copyright (c) 2010-2010: Joachim Faulhaber
Chris@16 3 +------------------------------------------------------------------------------+
Chris@16 4 Distributed under the Boost Software License, Version 1.0.
Chris@16 5 (See accompanying file LICENCE.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 +-----------------------------------------------------------------------------*/
Chris@16 8 #ifndef BOOST_ICL_CONCEPT_CONTAINER_HPP_JOFA_100923
Chris@16 9 #define BOOST_ICL_CONCEPT_CONTAINER_HPP_JOFA_100923
Chris@16 10
Chris@16 11 #include <boost/utility/enable_if.hpp>
Chris@16 12 #include <boost/mpl/and.hpp>
Chris@16 13 #include <boost/mpl/not.hpp>
Chris@16 14 #include <boost/icl/type_traits/is_container.hpp>
Chris@16 15 #include <boost/icl/type_traits/is_icl_container.hpp>
Chris@16 16
Chris@16 17 namespace boost{ namespace icl
Chris@16 18 {
Chris@16 19
Chris@16 20 //==============================================================================
Chris@16 21 //= Emptieness
Chris@16 22 //==============================================================================
Chris@16 23
Chris@16 24 /** Tests if the container is empty.
Chris@16 25 Complexity: constant. */
Chris@16 26 template<class Type>
Chris@16 27 typename enable_if<is_container<Type>, bool>::type
Chris@16 28 is_empty(const Type& object)
Chris@16 29 {
Chris@16 30 return object.begin()==object.end();
Chris@16 31 }
Chris@16 32
Chris@16 33
Chris@16 34 /** All content of the container is dropped.
Chris@16 35 Complexity: linear. */
Chris@16 36 template<class Type>
Chris@16 37 typename enable_if<is_container<Type>, void>::type
Chris@16 38 clear(Type& object)
Chris@16 39 {
Chris@16 40 object.erase(object.begin(), object.end());
Chris@16 41 }
Chris@16 42
Chris@16 43 //==============================================================================
Chris@16 44 //= Size
Chris@16 45 //==============================================================================
Chris@16 46
Chris@16 47 template<class Type>
Chris@16 48 typename enable_if<mpl::and_< is_container<Type>
Chris@16 49 , mpl::not_<is_icl_container<Type> > >
Chris@16 50 , std::size_t>::type
Chris@16 51 iterative_size(const Type& object)
Chris@16 52 {
Chris@16 53 return object.size();
Chris@16 54 }
Chris@16 55
Chris@16 56 //==============================================================================
Chris@16 57 //= Swap
Chris@16 58 //==============================================================================
Chris@16 59
Chris@16 60 template<class Type>
Chris@16 61 typename enable_if<is_container<Type>, void>::type
Chris@16 62 swap(Type& left, Type& right)
Chris@16 63 {
Chris@16 64 left.swap(right);
Chris@16 65 }
Chris@16 66
Chris@16 67 //==============================================================================
Chris@16 68 //= Iteration
Chris@16 69 //==============================================================================
Chris@16 70
Chris@16 71 template<class Type>
Chris@16 72 typename enable_if<is_container<Type>, typename Type::iterator>::type
Chris@16 73 cyclic_prior(Type& object, typename Type::iterator it_)
Chris@16 74 { return it_ == object.begin() ? object.end() : --it_; }
Chris@16 75
Chris@16 76 template<class Type>
Chris@16 77 typename enable_if<is_container<Type>, typename Type::const_iterator>::type
Chris@16 78 cyclic_prior(const Type& object, typename Type::const_iterator it_)
Chris@16 79 { return it_ == object.begin() ? object.end() : --it_; }
Chris@16 80
Chris@16 81
Chris@16 82
Chris@16 83 }} // namespace boost icl
Chris@16 84
Chris@16 85 #endif
Chris@16 86
Chris@16 87