CRTP - Checking from the base class that the derived one meets requirements
<p>The curiously recurring template pattern may be used to implement a sort of static polymorphism. For example:</p>

<pre><code>#include &lt;iostream&gt;

template&lt;
 class Derived
&gt;
struct Base
{
    static void print ( )
    {
        std::cout &lt;&lt; Derived::number_to_print &lt;&lt; '\n';
    }
};

struct Derived final :
    Base&lt;
     Derived
    &gt;
{
    static constexpr unsigned int number_to_print = 27;
};

int main ( )
{
    Derived::print();
}
</code></pre>

<p>This behaves as expected and prints <code>27</code>.</p>

<p>Now, I would like to add checks to the base class to assert that derived classes meet certain requirements. In the example given above, such checks could be:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;type_traits&gt;

template&lt;
 class Derived
&gt;
struct Base
{
    // --- Checks begin
    static_assert( std::is_same&lt;
         decltype(Derived::number_to_print),
         unsigned int
        &gt;::value,
        "static member `number_to_print' should be of type `unsigned int'" );
    // --- Checks end

    static void print ( )
    {
        std::cout &lt;&lt; Derived::number_to_print &lt;&lt; '\n';
    }
};

struct Derived final :
    Base&lt;
     Derived
    &gt;
{
    static constexpr unsigned int number_to_print = 27;
};

int main ( )
{
    Derived::print();
}
</code></pre>

<p>This doesn't work because, at the point where <code>Base&lt;Derived&gt;</code> is instantiated, <code>Derived</code> has only been forward-declared, i.e., it's incomplete, and nothing of it is yet known beyond the fact that it's a struct.</p>

<p>I've been scratching my head, as I think these checks could prove helpful to users of the base class, but haven't found any way to do this.</p>

<p>Is it possible?, and if so, how?</p>