tahoma2d/toonz/sources/include/tcg/boost/range_utility.h

53 lines
1.3 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TCG_BOOST_RANGE_UTILITY_H
#define TCG_BOOST_RANGE_UTILITY_H
// boost includes
#include <boost/range.hpp>
/*!
\file range_utility.h
\brief Contains utilities to be used with Boost.Range objects.
*/
2016-06-15 18:43:10 +12:00
namespace tcg {
2016-03-19 06:57:51 +13:00
//***************************************************************************
// Range utilities
//***************************************************************************
/*!
\brief Substitutes a container's content with the one inside
a \a Boost range.
\details The container type requires construction with an
iterator pair and the swap() method.
*/
template <typename C, typename Rng>
2016-06-15 18:43:10 +12:00
C &substitute(C &c, const Rng &rng) {
C(boost::begin(rng), boost::end(rng)).swap(c);
return c;
2016-03-19 06:57:51 +13:00
}
//------------------------------------------------------------------------
/*!
\brief Inserts a range inside an associative container.
\details The container type requires an insert() method
accepting a pair of iterators.
\note For insertion in a sequential container, use
<TT>boost::insert</TT>.
*/
template <typename C, typename Rng>
2016-06-15 18:43:10 +12:00
C &insert2(C &c, const Rng &rng) {
c.insert(boost::begin(rng), boost::end(rng));
return c;
2016-03-19 06:57:51 +13:00
}
2016-06-15 18:43:10 +12:00
} // namespace tcg
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
#endif // TCG_BOOST_RANGE_UTILITY_H