[PATCH] D25342: Turn cl::values() (for enum) from a vararg function to using C++ variadic template

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 14:09:44 PDT 2016


zturner added inline comments.


> CommandLine.h:586-588
>      for (size_t i = 0, e = Values.size(); i != e; ++i)
> -      O.getParser().addLiteralOption(Values[i].first, Values[i].second.first,
> -                                     Values[i].second.second);
> +      O.getParser().addLiteralOption(Values[i].Name, Values[i].Value,
> +                                     Values[i].Description);

Probably should change this to a range-based for.

> CommandLine.h:594-595
> +/// as an initializer list to the ValuesClass constructor.
> +template <typename... OptsTy> ValuesClass values(OptsTy... Options) {
> +  return ValuesClass({Options...});
>  }

Is this going to give you unwanted copies?  Is there any difference if you take the parameter pack by rvalue reference?

https://reviews.llvm.org/D25342





More information about the llvm-commits mailing list