Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. /std:c++20 broke a template class

/std:c++20 broke a template class

Scheduled Pinned Locked Moved ATL / WTL / STL
c++databasegraphicsdata-structureshelp
2 Posts 2 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_15671062
    wrote on last edited by
    #1

    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.
    
    
        }      
    

    }

    L 1 Reply Last reply
    0
    • M Member_15671062

      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.
      
      
          }      
      

      }

      L Offline
      L Offline
      longjmp
      wrote on last edited by
      #2

      typename std::vector::iterator p = m_vItems.begin();

      or

      auto p = m_vItems.begin();

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups