[PATCH] D24880: Add StringExtras join_items function

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 09:30:48 PDT 2016


Ok then.  I tested on MSVC and it works too.  I guess I got into the habit
of doing that for old versions of MSVC as a workaround.  Maybe it didn't
used to be able to disambiguate this correctly.

On Tue, Sep 27, 2016 at 9:21 AM David Blaikie <dblaikie at gmail.com> wrote:

> On Tue, Sep 27, 2016 at 9:03 AM Zachary Turner <zturner at google.com> wrote:
>
> zturner added inline comments.
>
> ================
> Comment at: include/llvm/ADT/StringExtras.h:226
> @@ +225,3 @@
> +  return join_one_item_size(A) +
> +         join_items_size(B, std::forward<Args>(Items)...);
> +}
> ----------------
> mehdi_amini wrote:
> > Do you need the B in this function?
> My understanding is that it is needed to disambiguate the two overloads.
> If you have these two:
>
> ```
> template <typename A1>
> size_t join_items_size(const A1 &A) {
> }
>
> template<typename A1, typename... As>
> size_t join_items_size(const A1 &A, As &&... Items) {
> }
> ```
>
> Then if you call it as:
>
> ```
> size_t x = join_items_size("Test");
> ```
>
> it will be ambiguous, because the second overload could have a parameter
> pack of size 0.  Correct me if I'm wrong though, I admit I am not an expert
> here :)
>
>
> A cursory test seems to work OK (does not have ambiguity):
>
> $ cat a.cpp
> template<typename T>
> void f(const T&);
>
> template<typename T, typename... Ts>
> void f(const T&, const Ts&...) = delete;
>
> void caller() {
>   f(3);
> }
> $ clang++-tot -std=c++11 a.cpp -fsyntax-only
> $
>
>
>
>
> https://reviews.llvm.org/D24880
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160927/5a955a52/attachment.html>


More information about the llvm-commits mailing list