pair.hpp
Go to the documentation of this file.
1
2#pragma once
3
4// Funnel:
5// This macro mostly used to put in arguments to macro behind macro.
6//
7// Why does we need this?:
8// #define My_2(X, y) .......
9//
10// But, if you put class template as macro argument, expanding macro gets messed up.
11// My_2(template<int, float>, template<A, B>) // in fact, preprocessor thought we 
12// passed 4 arguments, not 2.
13//
14// Then, Use Funnel macro instead:
15// My_2(BY_PAIR(MyMap<T, U>), BY_PAIR(template <typename T, typename U))
17#include "indep/macro/overload.hpp"
18
19#define BY_PAIR_1(x) x
20#define BY_PAIR_2(x, y) x, y
21#define BY_PAIR_3(x, y, z) BY_PAIR_2(x, y), z
22#define BY_PAIR_4(x, y, z, a) BY_PAIR_2(x, y), BY_PAIR_2(z, a)
23#define BY_PAIR(...) BY_OVERLOAD(BY_PAIR, __VA_ARGS__)