/std:c++20 broke a template class
ATL / WTL / STL
2
Posts
2
Posters
14
Views
1
Watching
-
Hi - I have a template array class based on a std::vector. All worked well w/ c++17, but there is one line I can't seem to port to the new standard. I'm trying to acquire an iterator to the underlying vector. Any advice is greatly appreciated. An abbreviated depiction:
template class CMy_Array
{private: std::vector m\_vItems; public: CMy\_Array() { } virtual ~CMy\_Array () { m\_vItems.clear(); } void InsertAt(int index) { // THE LINE IN QUESTION - trying to acquire an iterator... // this worked w/ std:c++17 - std::vector::iterator p = m\_vItems.begin(); // With c++20, 2 errors occur; // C2760 - syntax error: unexpected token 'identifier', expected ';' , and // C7510 - 'iterator': use of dependent type name must be prefixed with 'typename' // Using the documentation for C2760, I modified the line in question as so - std::vector::iterator p = static\_cast ::iterator> m\_vItems.begin(); // This eliminated the C7510 error, but C2760 remains. }
}
-
Hi - I have a template array class based on a std::vector. All worked well w/ c++17, but there is one line I can't seem to port to the new standard. I'm trying to acquire an iterator to the underlying vector. Any advice is greatly appreciated. An abbreviated depiction:
template class CMy_Array
{private: std::vector m\_vItems; public: CMy\_Array() { } virtual ~CMy\_Array () { m\_vItems.clear(); } void InsertAt(int index) { // THE LINE IN QUESTION - trying to acquire an iterator... // this worked w/ std:c++17 - std::vector::iterator p = m\_vItems.begin(); // With c++20, 2 errors occur; // C2760 - syntax error: unexpected token 'identifier', expected ';' , and // C7510 - 'iterator': use of dependent type name must be prefixed with 'typename' // Using the documentation for C2760, I modified the line in question as so - std::vector::iterator p = static\_cast ::iterator> m\_vItems.begin(); // This eliminated the C7510 error, but C2760 remains. }
}