Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range] Generating a singular range.
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-12-14 13:12:20


> Hi All
>
> Is there an easy and obvious way to construct a single element range
> from a value_type of that range?
>
> Thx
>
> - Rob.

How about:

template <typename T>
boost::iterator_range<T*> singular(T& t)
{
    return boost::make_iterator_range(&t, &t + 1);
}

Of course you'll want a const version as well.

Regards,
Nate
                                               


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net