Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T, class R>
- class Matcher {}; //на будущее
- template<class T, class R>
- class RevTuple
- {
- private:
- T value;
- R rest;
- public:
- template<typename N> struct RevType
- {
- typedef RevTuple<T, typename R::template RevType<N>::push_type> push_type;
- };
- typedef T data_type;
- typedef R pop_type;
- RevTuple(const T &val, const R &r):
- value(val), rest(r) {}
- T &GetValue() { return value; }
- R &GetRest() { return rest; }
- template<typename N>
- typename RevType<N>::push_type operator,(const N &val)
- {
- return typename RevType<N>::push_type(value, (rest, val));
- }
- Matcher<T, R> Match()
- {
- return Matcher<T, R>(*this);
- }
- };
- struct empty
- {
- template<typename N> struct RevType
- {
- typedef RevTuple<N, empty> push_type;
- };
- typedef empty data_type;
- typedef empty pop_type; //?
- template<typename N>
- typename RevType<N>::push_type operator,(const N &val)
- {
- return typename RevType<N>::push_type(val, *this);
- }
- };
- empty Rule()
- {
- return empty();
- }
- int main()
- {
- //int a, b, c;
- (Rule(), 1, 2);
- /*if (r.Match(), 1, &a, 3)
- std::cout << "Passed 1: " << a << std::endl;
- if (!(r.Match(), 1, 1, 3))
- std::cout << "Passed 2\n";
- if (r.Match(), a, 2, b)
- std::cout << "Passed 3: " << a << ", " << b << std::endl;*/
- }
Advertisement
Add Comment
Please, Sign In to add comment