I am having a problem when using the new C++11 using
keyword. As far as I understand, it's an alias for typedef
. But I cannot get it to compile. I want to define an alias for an iterator of a std::vector
. If I use this everything works perfectly.
typedef std::vector<fix_point>::iterator inputIterator;
But if I try:
using std::vector<fix_point>::iterator = inputIterator;
The code doesn't compile with:
Error: 'std::vector<fix_point>' is not a namespace
using std::vector<fix_point>::iterator = inputIterator;
^
Why doesn't this compile?
You just have it backwards:
using inputIterator = std::vector<fix_point>::iterator;
The alias syntax sort of mirrors the variable declaration syntax: the name you're introducing goes on the left side of the =
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With