vendredi 3 avril 2015

Declare "container" object from templated template class and variadic templates

I need to declare a class which could store different kind of containers. i.e. It would be nice if it could handle std::bitset and std::array. However, these two classes need a different of template arguments... Is it possible (and possibly, how) to use templated template classes and variadic templates to declare this kind of class?


Example (but wrong):



template<template <typename..., std::size_t> class Container,
std::size_t N,
typename... Args>
class Base_Class
{
...
Container<Args..., N/2> container;
};


The compiler complains that N/2 is not a type. Obviously, for both std::array and std::bitset I need the size to be the last template parameter... Is it possible to code this crazyness?


Thank you!


Aucun commentaire:

Enregistrer un commentaire