Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) 'MyPolicy::MyMethod' is not a direct base class of 'MyClass<MyPolicy>'

 

Compile error.

 

Full error message

 

 

[C++ Error] UnitMain.cpp(4): E2507 'MyPolicy::MyMethod' is not a direct base class of 'MyClass<MyPolicy>'

 

 

Cause

 

IDE: C++ Builder 6.0

Compiler: Borland BCC32.EXE version 6.0.10.157

 

 

template <typename MyPolicy>

struct MyClass : public MyPolicy

{

using MyPolicy::MyMethod;

};

 

 

This example is simplified from the example at the WikiPedia page about policy-based design.

 

The same code does compile using the IDE Dev-C++ version 4.9.9.2 its default compiler.

 

Solution

 

By removing the using statement, it will work.

 

 

template <typename MyPolicy>

struct MyClass : public MyPolicy

{

 

};

 

 

Policies requires a compiler with highly robust support for templates [0] .

 

 

 

 

 

References

[0]          The WikiPedia page about policy-based design

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.