Victor Bazarov wrote
> Mateusz Loskot wrote:
>
> ;
> ^^^
> Apparently, the semicolon is missing.
Yes.
> >
> > My questions are:
> >
> > - Is it safe to rename iterator as in this example
> > std::vector<T>::iterator to Iterator?
>
> You're not _renaming_ it.
Yes, "rename" is unfortunate here.
> You're introducing a _local_ *synonym* for it.
Definitely, "synonim" the right name.
> The locality is the scope of the 'C' class. And why do you ask?
> What could be _UN_safe about it?
I ask because I don't know if what I've introduced it fine or not.
> What are your concerns? You could
> have just used the non-capitalized version of the word, it would be
> probably simpler and more familiar for most who use iterators in
> their everyday C++ activities.
> Capitalization is awkward. Java-like.
Definitely, agreed.
First, I have types and methods named with first letter upper case (not
getMe but GetMe).
I know it's awkward, so please don't ask me why I use it

Simply, I
have to.
My question is of kind of this "Is that safe to use names with
double-/single- underscore as a first character?".
So, I hoped it will be clear why I ask.
> > - Is it safe to rename std::vector<T>::begin to Begin and
> > std::vector<T>::end to End?
>
> You're not _renaming_ anything here.
Yes, it's confirmed. "Synonim" is the right word.
> You're calling 'C's members
> whatever you would like them to be called. What's all the fuss
> about?
OK, I'm calling a member, that's clear and I get a typedef of
std::vector<T>::iterator, a synonim, so can I pass it to STL
algorithms?
Simply, is this code below OK regarding iterators usage?
std::vector<MyClass> v;
typedef std::vector<MyClass>::iterator ThisIsMySynonim;
ThisIsMySynonim MyBegin() { return v.begin(); }
ThisIsMySynonim MyEnd() { return v.end}
std::for_each(v.MyBegin(), v.MyEnd(), FunctorDefinedSomewhere());
> When you use objects of your 'C' class (BTW, names consisting of one
> letter only are really "unsafe", from maintenance point of vive)
It's a short for Usenet so the code does not occupy too much space in
post.
> Standard Library algorithms, for example, 'copy' or 'transform', you
> are _forced_ to spell out your names. The Standard Library algorithms
> do _not_ expect your objects to have "begin" and "end" functions.
And that's what I'm asking for too. Thanks.
> > - Any better recommendation?
>
> Unless you actually get an error, stop asking those nonsensical
> questions. Get a drink, go out, breathe some fresh air, ventilate
> your brain (but not by drilling more holes in your head).
> [...]
Hehe, you are definitely right. It was about 5 am so it was a good idea
to go to bed, no discussion here.
> > Simply, I'd like to get them more coherent with naming convention I
> > use in my project.
>
> Conventions are just that, conventions. You agree on something. It
> doesn't have to be "like everybody else", but it doesn't necessarily
> be "unlike everybody else's". Unless you experience some _trouble_,
> stop wasting your time on trying to figure out the best convention,
> just follow _one_ (and one in the Standard Library is not the worst).
>
Hm, interesting, I've read somewhere (I cannot recall where I read it,
may be in Scott Meyers' books, but I'm not sure now) that STL coding
style is just for STL and should not be followed in external
(non-STL/Standard C++) implementations. I've understood is just as
chapter 17.4.3.1.2 from C++ Standard, as a good recommendation.
Certainly, I may be wrong.
Thanks for your patience!
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net