4

Running gcc v3.4.6 on the Botan v1.8.8 I get the following compile time error building my application after successfully building 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 telling me? Here is a snippet of secmem.h 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!
[...]
Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
WilliamKF
  • 41,123
  • 68
  • 193
  • 295

1 Answers1

9

Change it to 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 looked up in a base class that depends on a template parameter. So 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 told to look into the scope of the class, and includes dependent base classes in that lookup.

Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
  • 1
    Dammit, Johannes! I thought you were a student?! Isn't there anything else you'd rather do on a Saturday night then steeling rep points from old men? `:)` +1 from me anyway. – sbi May 15 '10 at 20:49
  • 1
    @sbi i'm not so much party-compatible :) – Johannes Schaub - litb May 15 '10 at 20:54
  • 3
    partying is the one thing that takes much less than 10,000 hours to master. – wilhelmtell May 15 '10 at 20:57
  • Well, I'm with Wilhelm on that. (And, FWIW, I wouldn't think Giessen is all that party-compatible either. BICBW.) Anyway, should you happen to come by here (see profile), give me a hint and you're invited to a free beer with a grumpy old man. `:)` – sbi May 15 '10 at 21:16
  • @Wilhelm oh for poor nerdy litb it takes much more than that – Johannes Schaub - litb May 18 '10 at 15:37