Mathias said:
That makes perfectly sense though.
Why should you be allowed to modify rvalues?
You can already call a non-const member function of a temporary.
To help hell break loose?
No, but, e.g., to make working with proxy classes easier. Also, I just find
it silly that I can do
std::vector<int>().swap( some_int_vector );
but neither
std::swap( std::vector<int>(), some_int_vector );
nor
some_int_vector.swap( std::vector<int>() );
_Modifying_ temporaries is perfectly fine. I do it all the time. Hell does
not break loose. I do not see why _binding_ temporaries to non const
references is not fine. (I agree that there is a problem that arises from
temporaries created by automatic type conversion/promotion.)
To return useful information it would need to store them somewhere.
True. However, this information could be optimized away by the compiler if
global data flow analysis reveals that it's not used anywhere in the
compilation unit.
That could have been nice, indeed.
But no good way was thought of.
Sad but true.
This is not trivial to implement.
Implementors already had enough problems with export, so it is hard
asking for features needing collaborative work of both the compiler and
linker.
I know, it's tricky. Nonetheless, I'd love to have them.
You're confusing undefined and unspecified.
I don't think so.
And it has nothing to do with doubts.
That, maybe.
Variables should be perfectly workable upon declaration.
Since list<T> is a container of T's, T must be complete.
Recursive definitions do not really play well with this, indeed.
Well, the following compiles and works as expected with g++ (and I would
predict with most STL implementation):
#include <iostream>
#include <iterator>
#include <algorithm>
#include <list>
class recursive_list {
std::list< recursive_list > the_list;
public:
friend
std:
stream & operator<< ( std:
stream & o_str,
recursive_list const & rl ) {
if ( rl.the_list.empty() ) {
o_str << "[]";
} else {
o_str << "[ ";
std::copy ( rl.the_list.begin(),
rl.the_list.end(),
std:
stream_iterator<recursive_list>
( std::cout, " " ) );
o_str << "]";
}
return ( o_str );
}
void push_back ( recursive_list const & rl ) {
the_list.push_back( rl );
}
};
int main ( void ) {
recursive_list const empty_list;
recursive_list r1;
r1.push_back( empty_list );
r1.push_back( empty_list );
r1.push_back( empty_list );
r1.push_back( r1 );
r1.push_back( empty_list );
r1.push_back( empty_list );
r1.push_back( empty_list );
std::cout << r1 << '\n';
}
Intended output: [ [] [] [] [ [] [] [] ] [] [] [] ]
So it is possible (and already usual) to implement std::list<> the way I
would like. However, the code above has undefined behavior according to the
standard and is not even required to compile (but is permitted to): and
indeed, the code fails to compile when I build g++ with concept_checks
enabled.
There is one in the next standard.
That's good to know.
Of course you can.
It's just that members aren't virtual, so you can't do polymorphism with
them.
You can in all implementations that I have seen so far, yet there is no
guarantee in the standard. The type std::vector<T>::iterator is marked as
implementation defined: (a) it could be T* or (b) it could use a virtual
base trick to prevent derivation. At least the second point goes for all
iterator types. With regard to the container classes, I might be paranoid
in thinking that they could legally prevent derivation.
C++ only allow three ways to represent signed integrals.
Really? I recall that I once tried to deduce that from the standard and
that I failed.
Those are available in third party libraries.
True. However, this kind of thing can benefit tremendously from support by
compiler magic. In addition, standardization has more benefits that
providing availability. Anyway, the availability of third party libraries
makes this a minor nuisance, and I have already qualified this item as
such.
This is heavily platform specific.
So is IO. Yet still, the standard provides means for IO. Again, this is a
minor nuisance, and I might be argued that C++ could drop IO facilities
from the standard altogether.
Best
Kai-Uwe Bux