| 1 |
// PR c++/61647 |
| 2 |
|
| 3 |
class XX; |
| 4 |
|
| 5 |
template<typename Container, typename Key> |
| 6 |
struct Accessor; |
| 7 |
|
| 8 |
template<typename Container, typename Key, typename KeyStore = Key> |
| 9 |
class Variant { |
| 10 |
protected: |
| 11 |
KeyStore index; |
| 12 |
Container state; |
| 13 |
public: |
| 14 |
Variant(Container st, const Key& i) : index(i), state(st) {} |
| 15 |
|
| 16 |
template<typename T> |
| 17 |
operator T() const { |
| 18 |
return Accessor<Container, KeyStore>::template get<T>(state, index); |
| 19 |
} |
| 20 |
}; |
| 21 |
|
| 22 |
class AutoCleanVariant : public Variant<XX*, int> { |
| 23 |
public: |
| 24 |
AutoCleanVariant(XX* st, int i) : Variant<XX*,int>(st,i) {} |
| 25 |
|
| 26 |
template<typename T> |
| 27 |
operator T() const { |
| 28 |
return Variant<XX*, int>::operator T(); |
| 29 |
} |
| 30 |
}; |