Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Type1
- {
- public:
- template<typename T>
- Type& operator&(T t){t.serialize(*this);return *this;}
- template<>Type& operator&(int t){/*полезные действия*/return *this;}
- };
- class Type2
- {
- public:
- template<typename T>
- Type& operator&(T t){t.serialize(*this);return *this;}
- template<>Type& operator&(int t){/*полезные действия*/return *this;}
- };
- class C
- {
- int v;
- template<typename T> friend T& T::operator&(C);
- template <class T> T& serialize(T&t){t&v; return t;}
- public:
- ...
- };
- //------------------------------------------------------------------------------
- int _tmain(int argc, _TCHAR* argv[])//
- {
- Type t;
- C c;
- t & c & c & c;
- return 0;
- }
- template<typename T> friend class T;
- friend Type& Type::operator&(class C);
- friend Type& operator&(class Type,class C);
- template<class T>friend T& class T::operator&(C);
- template<typename T> friend T& T::operator& < T > (class C);
- class C
- {
- int v = 10;
- template<typename T> friend T& operator&(T&, const C&);
- template <class T> T& serialize(T&t) const { t&v; return t; }
- };
- template<typename T>
- T& operator&(T& t, const C& c)
- {
- c.serialize(t); return t;
- }
- class Type1
- {
- public:
- Type1& operator&(int t) {/*полезные действия*/return *this; }
- };
- class Type2
- {
- public:
- Type2& operator&(int t) {/*полезные действия*/return *this; }
- };
Add Comment
Please, Sign In to add comment