[PATCH] [libc++] Move enable_if to 2nd argument of std::vector(iterator, iterator) ctor

Matt Calabrese rivorus at gmail.com
Sat Sep 21 16:19:05 PDT 2013

On Sat, Sep 21, 2013 at 3:12 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> I don't believe this is a correct change.
>     std::vector<int> v( {}, my_weird_iterator );
> ... cannot deduce the type of `_InputIterator`.

This is a prime candidate for my function-template-parameter-default
enable_if approach. For details, see
By using this approach, you'd avoid any potential corner-case deduction
issues, since the SFINAE happens as a part of forming the template
parameter kind, separate from any function parameters themselves. The
documentation linked is for boost::enable_if, but it will work perfectly
fine with std::enable_if as well. If you use this approach, be sure that
the enable_if is used when forming the template parameter kind as is shown
in the documentation and not as a part of the default argument itself.

-Matt Calabrese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130921/df7278b8/attachment.html>

More information about the cfe-commits mailing list