[PATCH] D24880: Add StringExtras join_items function

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 09:21:29 PDT 2016


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/5110c38c/attachment.html>


More information about the llvm-commits mailing list