Is there a C++ library that wraps a internal type to be able to derive from that internal type?

Viewed 44

I have this template that wrap an unsigned integer type (any) :

    template<std::unsigned_integral T>
    struct base_dig_t 
    {T m_data;};

Then I have this template to modify the behavior of the arithmetic operators etc. :

    template<std::unsigned_integral T,apropied_number_concept<T> R>
    struct dig_t : 
           public base_dig_t<T> 
    {};

that it does not contain any more data member: only the modifications on the arithmetic operators.

BEGIN : CONTEXT

What I want to achieve:

I want hold in a Container with order base_dig_t<T> objects
from the derived dig_t<T,R> objects. The Container would hold the R template non-type argument for the correct function. The Container for dig_t<T,R>, would represent a number with some format, length and radix R. For example (supose that we have an enumerated type EF with the formats):

template<typename T, T R,EF f, std::size_t length>
struct number_t : 
    public std::array<base_dig_t<T>,length>
{
    // It works with dig_t<T,R>
    // The behavior of this container vary with `f`
};

END : CONTEXT

But I think that this code have to exits out there. Is it true?

0 Answers
Related