Re: Const Considerations
Denise Kleingeist wrote:
James Kanze wrote:
Mulitple return values would change a lot if we also had
multiple assigns, like some languages. But we don't, and I
can't quite see how to make them fit into the C++ grammar.
Multiple returns and multiple assigns already arrived in C++:
std::tr1:tuple<int, double, std::string> f() {
return std::tr1::make_typle(1, 1.0, "one");
}
int main() {
int i = 0;
double d = 0;
std::string s = "zero";
std::tr1::tie(i, d, s) = f();
}
Yes, but it requires a different syntax:-). And does it support
things like:
std::tr1::tuple< int, double > f() { ... }
std::tr1::tie( i, d, s ) = ??( f(), "some text" ) ;
Not sure what syntax would be appropriate for the last part.
It's probably sufficient for most uses, but I still can't quite
see myself writing:
std::tie( x, y ) = std::tuple< int, int >( y, x ) ;
instead of:
std::swap( x, y ) ;
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]