What problems with C ++ are created with this error?

Running gcc v3.4.6 on Botan v1.8.8 I received the following compile-time error by creating my application after successfully creating Botan and running its self-test:

../../src/Botan-1.8.8/build/include/botan/secmem.h: In member function `Botan::MemoryVector<T>& Botan::MemoryVector<T>::operator=(const Botan::MemoryRegion<T>&)': ../../src/Botan-1.8.8/build/include/botan/secmem.h:310: error: missing template arguments before '(' token 

What is this compiler error? Here is the secmem.h snippet that includes line 310:

 [...] /** * This class represents variable length buffers that do not * make use of memory locking. */ template<typename T> class MemoryVector : public MemoryRegion<T> { public: /** * Copy the contents of another buffer into this buffer. * @param in the buffer to copy the contents from * @return a reference to *this */ MemoryVector<T>& operator=(const MemoryRegion<T>& in) { if(this != &in) set(in); return (*this); } // This is line 310! [...] 
+4
source share
1 answer

Change it like this:

 { if(this != &in) this->set(in); return (*this); } 

I suspect that the set function is defined in the base class? Unqualified names are not displayed in the base class, which depends on the template parameter. Therefore, in this case, the name set is probably associated with the std::set template, which requires template arguments.

If you qualify the name with this-> , the compiler is explicitly invited to look into the scope of the class and includes dependent base classes in this search.

+10
source

Source: https://habr.com/ru/post/1309878/


All Articles