Alf P. Steinbach escreveu:
>namespace {
using namespace std;
typedef map<string, intWord_Map;
// typedef Word_Map::value_type Word_Map_Pair;
The commented definition would effectively define (note the const, which
makes the type non-assignable)
typedef pair< string const, int Word_Map_Pair;
I couldn't realize (remember) that the /map::value_type/ typedef is of
the form pair<const Key, T>. Thanks for pointing it out.
By the way, note that your naming convention is formally invalid.
An underscore can't be followed by an uppercase letter, it is reserved
for implementation names.
You know, I've always been a "camelCaser", of the kind who thought
underscores were really ugly. It was only *very* recently that I allowed
myself to have a different appreciation of underscores. The
experimentation is still in progress.
As for the implementation-reserved forms, I thought they concerned only
the cases where an uppercase letter follows an underscore at the
beginning of an identifier. But anyway, rusty as I am now, it's very
likely that I am missing something.
>int main(int argc, char* argv[]) {
Please don't include things such as unused arguments that cause warnings.
Aim for 100% clean compiles.
Sorry about that. The code posted is a trimmed-down version of a
slightly larger program where command line arguments are indeed used. I
just forgot to remove them here.
However, using the non-assignable version of Word_Map_Pair as a
container element type is formally Undefined Behavior, and a good
compiler + library implementation will then issue diagnostics.
Thanks, Alf. Got it now.
Cheers,
--
Ney André de Mello Zunino