Boost logo

Boost :

Subject: Re: [boost] [c++TR2] N3334, Proposing array_ref<T> and string_ref
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-01-31 14:02:54


On Tue, Jan 31, 2012 at 7:57 PM, Yakov Galka <ybungalobill_at_[hidden]> wrote:
> b) Add *one* implicit constructor to array_ref:
>
> template<class R> array_ref(const R& x,
>        typename enable_if<
>                is_base_of<
>                        contiguous_iterator_tag,
>                        typename iterator_traits<
>                                decltype(begin(x))
>                        >::iterator_category
>                >::value,
>                int
>        >::type = 0);
> // use &*begin(x), (end(x) - begin(x)) to initialize.

You should check whether the range is empty before dereferencing begin().

Olaf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk