Chromium Code Reviews| Index: Source/wtf/UnionType.h |
| diff --git a/Source/wtf/UnionType.h b/Source/wtf/UnionType.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dd13f20d65a4a77ceb45723009f03925115f02cc |
| --- /dev/null |
| +++ b/Source/wtf/UnionType.h |
| @@ -0,0 +1,48 @@ |
| +#ifndef UnionType_h |
|
kojih
2013/05/15 09:28:26
I don't confident where to place this file.
Do you
|
| +#define UnionType_h |
| + |
| +namespace WTF { |
| + |
| +template<typename Type0, typename Type1> |
| +class UnionType2 { |
| +public: |
| + UnionType2() |
| + { |
| + } |
| + UnionType2(PassRefPtr<Type0> value) |
| + { |
| + value0 = value; |
| + } |
| + UnionType2(PassRefPtr<Type1> value) |
| + { |
| + value1 = value; |
| + } |
| + bool isNull() const |
| + { |
| + return !value0 && !value1; |
| + } |
| + bool isValue0Enabled() const |
| + { |
| + return !value0; |
| + } |
| + PassRefPtr<Type0> getValue0() const |
| + { |
| + return value0; |
| + } |
| + bool isValue1Enabled() const |
| + { |
| + return !value1; |
| + } |
| + PassRefPtr<Type1> getValue1() const |
| + { |
| + return value1; |
| + } |
| +private: |
| + RefPtr<Type0> value0; |
| + RefPtr<Type1> value1; |
| +}; |
| + |
| + |
| +} // namespace WTF |
| + |
| +#endif // UnionType_h |