mercredi 1 avril 2020

Extract value of template parameter from an alias template

I am making an alias template of Eigen's Matrix class and I was wondering if it was possible to extract the value from one of the "unused" template parameters.

enum MatrixType{
    FOO,
    BAR
};
template<int ROWS, int COLS, MatrixType FOO>
using Matrix = Eigen::Matrix<double, ROWS, COLS>

I want to be able to extract the MatrixType value at a later point (specifically within the MatrixBase plugin but unrelated). I've seen the approaches on this site such as:

template<template <MatrixType> typename T, MatrixType N>
constexpr MatrixType extract(const T<N>&) { return N; }

But I haven't been able to quite line it up with my specific situation. Thanks for any guidance.

Aucun commentaire:

Enregistrer un commentaire