M
Mateusz Loskot
Hi,
I have a simple question about naming convention, recommeded names or
so in following case.
I have a class which is implemented with one of STL container
(aggregated) and my aim is to expose iterators to enable user of my
class to iterate through this container content.
Here is a piece of code:
class A;
class C
{
std::vector<A*> v;
public:
// ...
typedef std::vector<Layer*>::iterator Iterator; // 1)
Iterator Begin() { return v.begin(); } // 2)
Iterator End() { return v.begin(); } // 3)
}
Obviously, in line 1) I'm declaring another (typedef) name for
std::vector<Layer*>::iterator.
In lines 2) and 3) I have accessor to std::vector<Layer*> iterators.
My questions are:
- Is it safe to rename iterator as in this example
std::vector<T>::iterator to Iterator?
- Is it safe to rename std::vector<T>::begin to Begin and
std::vector<T>::end to End?
- Are those names safe in case of using objects of C class in STL
algorithms?
- Any better recommendation?
What's the purpose of those names?
Simply, I'd like to get them more coherent with naming convention I use
in my project.
Cheers
I have a simple question about naming convention, recommeded names or
so in following case.
I have a class which is implemented with one of STL container
(aggregated) and my aim is to expose iterators to enable user of my
class to iterate through this container content.
Here is a piece of code:
class A;
class C
{
std::vector<A*> v;
public:
// ...
typedef std::vector<Layer*>::iterator Iterator; // 1)
Iterator Begin() { return v.begin(); } // 2)
Iterator End() { return v.begin(); } // 3)
}
Obviously, in line 1) I'm declaring another (typedef) name for
std::vector<Layer*>::iterator.
In lines 2) and 3) I have accessor to std::vector<Layer*> iterators.
My questions are:
- Is it safe to rename iterator as in this example
std::vector<T>::iterator to Iterator?
- Is it safe to rename std::vector<T>::begin to Begin and
std::vector<T>::end to End?
- Are those names safe in case of using objects of C class in STL
algorithms?
- Any better recommendation?
What's the purpose of those names?
Simply, I'd like to get them more coherent with naming convention I use
in my project.
Cheers