diff options
author | John Hodge <tpg@mutabah.net> | 2016-01-30 15:41:15 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-01-30 15:41:15 +0800 |
commit | e3cf598517bf45317df0891462d71fa0b20dd1b9 (patch) | |
tree | 9c359e49507faa9c36e0c3ebb6612a8c26271a0a /src/types.hpp | |
parent | bc4c6189980d2fc1c8e753b9cd614699652ecba7 (diff) | |
download | mrust-e3cf598517bf45317df0891462d71fa0b20dd1b9.tar.gz |
A whole lot of messing around for not much
Diffstat (limited to 'src/types.hpp')
-rw-r--r-- | src/types.hpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/types.hpp b/src/types.hpp index 9146d971..ef3e4d1d 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -110,8 +110,8 @@ public: {
switch( other.m_data.tag() )
{
- #define _COPY(VAR) case TypeData::VAR: m_data = TypeData::make_##VAR(other.m_data.as_##VAR()); break;
- #define _CLONE(VAR, code...) case TypeData::VAR: { auto& old = other.m_data.as_##VAR(); m_data = TypeData::make_##VAR(code); } break;
+ #define _COPY(VAR) case TypeData::TAG_##VAR: m_data = TypeData::make_##VAR(other.m_data.as_##VAR()); break;
+ #define _CLONE(VAR, code...) case TypeData::TAG_##VAR: { auto& old = other.m_data.as_##VAR(); m_data = TypeData::make_##VAR(code); } break;
_COPY(None)
_COPY(Any)
_COPY(Unit)
@@ -247,22 +247,20 @@ public: //}
const TypeRef& inner_type() const {
- switch(m_data.tag())
- {
- case TypeData::Borrow: return *m_data.as_Borrow().inner;
- case TypeData::Pointer: return *m_data.as_Pointer().inner;
- case TypeData::Array: return *m_data.as_Array().inner;
- default: throw ::std::runtime_error("Called inner_type on non-wrapper");
- }
+ TU_MATCH_DEF(TypeData, (m_data), (e),
+ ( throw ::std::runtime_error("Called inner_type on non-wrapper"); ),
+ (Borrow, return *e.inner; ),
+ (Pointer, return *e.inner; ),
+ (Array, return *e.inner; )
+ )
}
TypeRef& inner_type() {
- switch(m_data.tag())
- {
- case TypeData::Borrow: return *m_data.as_Borrow().inner;
- case TypeData::Pointer: return *m_data.as_Pointer().inner;
- case TypeData::Array: return *m_data.as_Array().inner;
- default: throw ::std::runtime_error("Called inner_type on non-wrapper");
- }
+ TU_MATCH_DEF(TypeData, (m_data), (e),
+ ( throw ::std::runtime_error("Called inner_type on non-wrapper"); ),
+ (Borrow, return *e.inner; ),
+ (Pointer, return *e.inner; ),
+ (Array, return *e.inner; )
+ )
}
//::std::vector<TypeRef>& sub_types() { return m_inner_types; }
//const ::std::vector<TypeRef>& sub_types() const { return m_inner_types; }
|