jeudi 27 avril 2017

custom template programming

I am trying to write a container class that changes behavior depending on the based on a given dimension of the class as follow:

template <typename T, size_t DIM>
class Container { ... };

I tried to achieve that by using type_triats as follow:

template<typename T, size_t DIM, typename ENABLE = typename std::enable_if<
        std::integral_constant<bool, DIM == 1>::value>::type>
{ // implementation for 1D };

and for 2 d container as follow:

template<typename T, size_t DIM, typename ENABLE = typename std::enable_if<
            std::integral_constant<bool, DIM == 2>::value>::type>
    { // implementation for 2D };

by I get redefenition error ?! is type of Container and Container the same ?!!

Any idea how I can implement this customization.

Aucun commentaire:

Enregistrer un commentaire