C++ instance counter
Nice use of the "Curiously Recurring Template Pattern".

The trouble with your design, is that any user of your class needs to declare their own version of the s_counter. Not strictly a problem but it does make it harder to use.

I would use static function variable as the counter. That way you don't actually need to declare your own version.

    struct counter
    {
        private:
            // Should not be used by friends.
            static std::atomic&lt;uint32_t&gt;&amp; getCounterInstance() {
                static std::atomic&lt;uint32_t&gt;  counter = 0;
                return counter;
            }
    };


As counter is a private member of countable. Nobody else can see it (let alone access it). So you don't need to make countable a friend. Just use some standard public functions to get you accesses.

template&lt;typename t_derived&gt;
class countable
{
    struct counter
    {
        private:
            // Should not be used by friends.
            static std::atomic&lt;uint32_t&gt;&amp; getCounterInstance() {
                static std::atomic&lt;uint32_t&gt;  counter = 0;
                return counter;
            }

       public:
            // Handy access methods:
            static void incrementCounter() {
                ++getCounterInstance();
            }
            static void decrementCounter() {
                --getCounterInstance();
            }
    };
};


The only person that has access to incrementCounter() and decrementCounter() are members of countable.

You got the default constructor and the copy constructor.

    countable()
    {
        ++counter::s_counter;
    }

    countable(const countable&amp;)
    {
        ++counter::s_counter;
    }


But you forgot the move constructor.

    countable(countable&amp;&amp;)
    {
        counter::incrementCounter();
    }