Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <tuple>
- #include <iostream>
- using namespace std;
- template <int i, typename Tuple, typename T0>
- bool myequal(Tuple& t, T0 const & head){
- if(get<i>(t) == head)
- return true;
- else
- return false;
- }
- template <int i, typename Tuple, typename T0, typename ... Types>
- bool myequal(Tuple& t, T0 const & head, Types ... tail){
- if(get<i>(t) == head && myequal<i+1, Tuple, Types ...>(t, tail...))
- return true;
- else
- return false;
- }
- main(){
- tuple<int, char> t(10, 'a');
- cout << myequal<0, decltype(t), int, char>(t, 10, 'a') << endl;
- cout << myequal<0, decltype(t), int, char>(t, 11, 'a') << endl;
- cout << myequal<0, decltype(t), int, char>(t, 11, 'b') << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment