| template <class T1, class T2, bool is_reference> | |
| struct MyPairBase; | |
| // Dispatch the reference specialisation and use it as a storage. | |
| template <class T1, class T2> | |
| struct MyPairBase<T1, T2, false> { | |
| T1 a; | |
| T2 b; | |
| MyPairBase& operator=(const MyPairBase& other) = default; | |
| }; | |
| template <class T1, class T2> | |
| struct MyPairBase<T1, T2, true> { | |
| T1 a; | |
| T2 b; | |
| MyPairBase& operator=(const MyPairBase& other) { | |
| a = other.a; | |
| b = other.b; | |
| return *this; | |
| } | |
| // Possibly we will need to copy many things there. | |
| }; | |
| template <class T1, class T2> | |
| struct MyPair : public MyPairBase<T1, T2, std::is_reference<T1>::value || | |
| std::is_reference<T2>::value> { | |
| using Base = MyPairBase<T1, T2, std::is_reference<T1>::value || | |
| std::is_reference<T2>::value>; | |
| // ... all the implementation | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment