2011/8/29 Martin B. <0xCDCDCDCD@gmx.at>:
On 26.08.2011 20:21, Ovanes Markarian wrote:
On Fri, Aug 26, 2011 at 2:30 PM, Martin B. <0xCDCDCDCD@gmx.at <mailto:0xCDCDCDCD@gmx.at>> wrote:
Hi!
Say I have a range R and I want to construct a new container from the range R. Will I always have to repeat the expression yielding the range, or is there a shorter way?
I do something like this: template <class SinglePassRange> boost::container::vector<typename boost::range_value<SinglePassRange>::type> makeVector(const SinglePassRange& rng) { boost::container::vector<typename boost::range_value<SinglePassRange>::type> v(boost::begin(rng), boost::end(rng)); return move(v); } and using it surprisingly often as move semantics allow for cheap return-by-value I guess you would also add template parameter for container type. -- Szymon Gatner The Lordz Games Studio www.thelordzgamesstudio.com