I was wondering is there any way of doing something like this:
Template<class T, int node_1, int node_2>
class Node_
{
private:
//stuff goes here
public:
bool operator==(const Node<T,node_1,node_2> &rhs) const
{
//stuff goes here.
}
**Test.cpp**
#include "Node.h"
//all includes
template <int node_1, int node_2>
using NodeD = Node<double, node_1, node_2>;
void test_it_by_comparing()
{
using NodeDRC = NodeD<node_1, node_2>;
using NodeDCR = NodeD<node_2, node_1>;
//observe position of non-type node_1 and node_2.
using NodeD0 = NodeD<0, 0>;
constexpr int node_1 = 2;
constexpr int node_2 = 4;
double v=1.;
assert("compare check"&& !(MatrixDCR(v) == MatrixDRC(v)));
assert("compare check" && MatrixD0(0) != MatrixDRC(v));
assert("compare check" && !(MatrixD0(0) == MatrixDRC(v)));
}
It is forcing me to implement different number of same operator to accept appropriate type because node_1 and node_2 template parameters switch positions.
I would appreciate if anyone can solve this issue.
Aucun commentaire:
Enregistrer un commentaire