Topic: Concatenating tuples
Author: Greg Herlihy <greghe@pacbell.net>
Date: Thu, 5 Jul 2007 14:18:28 CST Raw View
I noticed that in this C++09x proposal for concatenating tuples:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2299.html
there is no mention given to the idea of overloading the plus operator
(+) to allow one tuple to be "added" to another (just as std::string
objects can be combined.) Offhand, I would think an overloaded plus
operator would make a lot of sense in this case, but perhaps there are
arguments against the idea. So, I guess my question is: would an
overloaded plus operator be a reasonable way to concatenate two tuple
objects of (possibly) differing types?
Greg
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Fri, 6 Jul 2007 18:31:08 CST Raw View
On 5 Jul., 22:18, Greg Herlihy <gre...@pacbell.net> wrote:
> I noticed that in this C++09x proposal for concatenating tuples:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2299.html
>
> there is no mention given to the idea of overloading the plus operator
> (+) to allow one tuple to be "added" to another (just as std::string
> objects can be combined.) Offhand, I would think an overloaded plus
> operator would make a lot of sense in this case, but perhaps there are
> arguments against the idea. So, I guess my question is: would an
> overloaded plus operator be a reasonable way to concatenate two tuple
> objects of (possibly) differing types?
Although operator+ is probably the most frequent used symbolic
concatenator for strings, several people have argued, that it is not
the most reasonable one, argueing from commutativity of +, which
does not fit well with contatenations. One of the rare exceptions
here is the usage of the asymmetric operator // in Fortran 90
to concatenate strings (which would not be allowed in C++).
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2233.html
has proposed to add operator<< for strings, so what about this?
Personally I don't expect a very frequent usage of the capability
to concatenate tuples - but maybe I have a false impression on that?
Greetings from Bremen,
Daniel Kr gler
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]