Peng Yu | 3 Sep 21:56

min function that accepts any number of arguments

Hi,

std::min accepts only two arguments. When I have more than two
arguments to compare, it becomes inconvenient. I'm wondering it is
possible to added a min function that accepts any number of arguments
in the future version of boost?

Thanks,
Peng
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Michael Fawcett | 3 Sep 22:12

Re: min function that accepts any number of arguments

On Wed, Sep 3, 2008 at 3:58 PM, Peng Yu <pengyu.ut <at> gmail.com> wrote:
>
> std::min accepts only two arguments. When I have more than two
> arguments to compare, it becomes inconvenient. I'm wondering it is
> possible to added a min function that accepts any number of arguments
> in the future version of boost?

I emailed a version that did this to Hervé Brönnimann and Doug Gregor
I believe.  Hervé said that he would try to include it in a future
Boost release.

FWIW, I used variadic templates, so unless you have a compiler that
supports them, my solution is interesting only in an academic sense.

--Michael Fawcett
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Sebastian Redl | 3 Sep 22:11
Favicon

Re: min function that accepts any number of arguments

Peng Yu wrote:
> Hi,
>
> std::min accepts only two arguments. When I have more than two
> arguments to compare, it becomes inconvenient. I'm wondering it is
> possible to added a min function that accepts any number of arguments
> in the future version of boost?
>   
Yes, it could probably be done with pseudo-vararg preprocessor magic.

However, the next standard contains a real vararg min. Given that, the 
question is how many people are willing to invest the effort. 
Pseudo-vararg code is a mess.

Sebastian
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Peng Yu | 3 Sep 22:27

Re: min function that accepts any number of arguments

On Wed, Sep 3, 2008 at 3:11 PM, Sebastian Redl
<sebastian.redl <at> getdesigned.at> wrote:
> Peng Yu wrote:
>>
>> Hi,
>>
>> std::min accepts only two arguments. When I have more than two
>> arguments to compare, it becomes inconvenient. I'm wondering it is
>> possible to added a min function that accepts any number of arguments
>> in the future version of boost?
>>
>
> Yes, it could probably be done with pseudo-vararg preprocessor magic.
>
> However, the next standard contains a real vararg min. Given that, the
> question is how many people are willing to invest the effort. Pseudo-vararg
> code is a mess.

Since Pseudo-vararg code is a mess, we may not what to do it at this
moment. But GCC has an option -std=c++0x, can the variadic version min
(non-pseudo) be added in boost at least to support GCC before the
upcoming C++ standard finalized?

Thanks,
Peng
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Scott McMurray | 3 Sep 22:33

Re: min function that accepts any number of arguments

On Wed, Sep 3, 2008 at 16:27, Peng Yu <pengyu.ut <at> gmail.com> wrote:
>
> Since Pseudo-vararg code is a mess, we may not what to do it at this
> moment. But GCC has an option -std=c++0x, can the variadic version min
> (non-pseudo) be added in boost at least to support GCC before the
> upcoming C++ standard finalized?
>

I suspect that if you have the GCC that supports it, you can also get
the libstdc++ that has a variable-argument min.  (Or an
initializer-list version, if the paper from the lastest mailing goes
through.)
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

David Abrahams | 4 Sep 01:16
Favicon
Gravatar

Re: min function that accepts any number of arguments


on Wed Sep 03 2008, "Peng Yu" <pengyu.ut-AT-gmail.com> wrote:

> Hi,
>
> std::min accepts only two arguments. When I have more than two
> arguments to compare, it becomes inconvenient. I'm wondering it is
> possible to added a min function that accepts any number of arguments
> in the future version of boost?

There's always std::min_element :-)

--

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Gmane