[PATCH] c++0x variadic min, max and minmax.

Chris Fairles chris.fairles@gmail.com
Fri Jul 11 15:49:00 GMT 2008


On Fri, Jul 11, 2008 at 10:15 AM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> Hi Chris,
>
> and sorry for some delays...
>
>> If it does stay, I assume I also have to add the fwd decl's
>> to stl_algofwd? And by doing so, the enable_if's need the variadic
>> versions of is_same. Could we make a variadic __is_same extension
>> in ext/type_traits.h perhaps so that its available to both algofwd
>> and algobase?
>
> Good question. Now, as regards the variadic is_same, I think we should ponder this thread:
>
>  http://tinyurl.com/567ner
>
> In other terms, assuming that the variadic versions of those algos will stay, I suspect the implementation will be much easier with Concepts available... What do you think?
>
> Paolo.
>

N2696 ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2696.pdf
) in section 25.7.3 there are notes that they currently cannot specify
requirements in concept syntax for the variadic min/max with custom
comparer so I'm not sure if the implementations will be any easier
with concepts given the current specification. Then again, I can't see
the committee leaving the custom-compare versions unconstrained or use
template meta-programming for those overloads and concept requirements
for the others.

The min/max versions w/o custom comparer seems like it will be trivial
to implement

template<LessThanComparable T, LessThanComparable... Args>
  requires SameType<T, Args>...
const T& min(const T& t, const T&... args) ... etc.

No need for std::is_same variadic or not. (I tried in conceptgcc with
no luck, I dont think variadic concepts are supported).

Personally I think a variadic is_same is *currently* useful outside
the stdlib as well and since its obviously not hard to implement and
currently every stdlib implementation will most likely need it. Its
like the ratio argument, if its required to implement parts of the
stdlib and its functionality is generic and well defined, then might
as well expose it to users. Then again, concepts will  turn everything
on its head in a way that obsoletes a LOT of the type-trait
meta-programming tricks implementations currently use and also in a
way that's not entirely clear to me (like with SameType, why even have
an is_same type trait?)

Chris



More information about the Libstdc++ mailing list