我想写这个函数find:
multi_set<int, string, double, myType> m; //vector of tuples
m.insert(/*some data*/);
m.find<1,2>("something",2.123);
Run Code Online (Sandbox Code Playgroud)
要么
m.find<0,3>(1,instanceOfMyType);
m.find<1>("somethingelse");
Run Code Online (Sandbox Code Playgroud)
哪里find可以参数化对应于元组参数的任何子集.
我的代码到目前为止:
template <typename ... T>
class multi_set{
typedef tuple < T... > Tuple;
vector<tuple<T...>> data = vector<tuple<T...>>();
public:
void insert(T... t){
data.push_back(tuple<T...>(t...));
}
template<size_t ... Pos>
void find(???){
// then I would like to use those params to search through data and
// return first matching item
}
}
Run Code Online (Sandbox Code Playgroud)