Does G ++ not allow the use of a protected default constructor in a base class when both are templates?

I created a header for optionally lazy parameters (also visible on GitHub repository).

In my original version of the code, I provided a protected default constructor for my base class template:

template <typename VAL_TYPE> class LazyType_Base { // .... LazyType_Base(void) =default; // .... 

Then in one of the derived classes:

 template <typename VAL_TYPE> class LazyType_Eager : public LazyType_Base<VAL_TYPE> { public: LazyType_Eager( VAL_TYPE&& final_val) : LazyType_Base<VAL_TYPE>{} , val_{final_val} {} // ..... 

This compiles simply using Clang ++, but in g ++ 5.1 I get this error:

 In file included from Test_OptionallyLazy.cpp:3:0: OptionallyLazy.hpp: In instantiation of 'LazyType_Eager<VAL_TYPE>::LazyType_Eager(VAL_TYPE&&) [with VAL_TYPE = int]': Test_OptionallyLazy.cpp:22:14: required from here OptionallyLazy.hpp:23:5: error: 'LazyType_Base<VAL_TYPE>::LazyType_Base() [with VAL_TYPE = int]' is protected LazyType_Base(void) =default; ^ OptionallyLazy.hpp:58:23: error: within this context , val_{final_val} 

What's going on here? The strangest bit is that another derived class is doing something similar that does not cause an error.

Replacing the constructor =default with an explicit =default implementation {} fixes the compiler error.

EDIT: Thanks to TC, here is a real MCVE:

 class Meow { protected: Meow(void) =default; public: virtual void f() {} }; class Purr : public Meow { public: Purr() : Meow{} {} }; 
+3
c ++ protected templates c ++ 14
source share

No one has answered this question yet.

See similar questions:

7
Virtual destructor changes decltype behavior

or similar:

148
How can I call :: std :: make_shared in a class with only protected or private constructors?
eleven
Explicitly create a template template for a template
8
C ++ template copy constructor in a template class
8
The protected class inheritance class is not called from the static template method of the base class
8
Auto constructor in an explicitly created class template
7
Virtual destructor changes decltype behavior
4
Disable the default copy construct and assign a constructor when using template constructors
one
std :: vector <> The default constructor does not exist after using the constructor from the base class and overloading the derived class
0
Using the base class constructor to protect it
0
Explicitly instantiating a class template that does not create a constructor

All Articles