In my development environment there is RHEL 5.8, which does not support GCC 4.8+ compilers (C ++ 11 +). I expect that someday we will get there, so I have a header file where I define macros based on C ++ 11 support levels, so I can do something like this:
#if defined(CPP11_auto_type_inference) && defined(CPP11_range_based_for_loops)
for (auto vit : args)
#else
std::vector<std::string>::const_iterator vit, vend;
for (vend=args.end(),vit=args.begin(); vit != vend; ++vit)
#endif
{
std::cout << "Processing \"" << *vit << '"' << std::endl;
. . .
}
So, what I'm trying to do in C ++ 98 is equivalent to the reference iterator (or more precisely say "dereferenced iterator"?), As shown below:
for (auto& it : args)
std::cout << "Processing \"" << it << '"' << std::endl;
Throughout life, I cannot figure out how to get a dereferenced iterator (or iterator reference) in C ++ 98. I can mimic it, as shown below:
#if defined(CPP11_auto_type_inference) && defined(CPP11_range_based_for_loops)
for (auto& it : args) {
#else
std::vector<std::string>::const_iterator vit, vend;
for (vend=args.end(),vit=args.begin(); vit != vend; ++vit) {
std::string it(*vit);
#endif
std::cout << "Processing \"" << it << '"' << std::endl;
. . .
}
... but I really hope this is not the answer.
++ 98 for (auto& it : vec)
, ? "" , ?
, " " ++ 11 auto&
? ( , ). , for (auto& it : vec)
, for (auto it : vec)
?
.