This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 4/4] std::regex refactoring


On 8 November 2013 14:51, Daniel Krügler wrote:
> I have fully not grasped for which T the specializations of
> __has_contiguous_iter are intended to be used,

Currently, only std::container iterators passed to a basic_regex
constructor, but in theory the trait could get moved to another header
and used elsewhere in future.

> but given the fact that
>
> +  template<typename _Tp, typename _Alloc>
> +    struct __has_contiguous_iter<std::vector<_Tp, _Alloc>>
> +    : std::true_type
> +    { };
>
> exists I think you really want to exclude any vector<bool, Allocator>
> by additionally adding
>
> +  template<typename _Alloc>
> +    struct __has_contiguous_iter<std::vector<bool, _Alloc>>
> +    : std::false_type
> +    { };

Hmm, I didn't think of that, damn vector<bool>!  It's only needed in
case someone does this:

  std::vector<bool> v;
  std::regex re(v.begin(), v.end());

which would be pretty crazy, but it has well-defined behaviour and
should throw regex_error.

I'll add the specialization, thanks for catching it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]