summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-07-14 14:39:18 +0200
committerljfa-ag <ljfa-ag@web.de>2015-07-14 14:39:18 +0200
commit6ec54ee1766a1819d62771620e91328a188341d2 (patch)
treeb15a665a2397719e6cf9826f35debabee227c8e7 /include
parentac24220bedd41cd0f811f70f9b0f65fa14c04589 (diff)
downloadProject-Tick-6ec54ee1766a1819d62771620e91328a188341d2.tar.gz
Project-Tick-6ec54ee1766a1819d62771620e91328a188341d2.zip
Turn tag_list::of into a subtype of tag_list
So we can get rid of the double braces :3
Diffstat (limited to 'include')
-rw-r--r--include/tag_list.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/include/tag_list.h b/include/tag_list.h
index 94403119dc..c97aaed66d 100644
--- a/include/tag_list.h
+++ b/include/tag_list.h
@@ -42,17 +42,13 @@ public:
typedef std::vector<value>::iterator iterator;
typedef std::vector<value>::const_iterator const_iterator;
+ template<class T>
+ class of;
+
///The type of the tag
static constexpr tag_type type = tag_type::List;
/**
- * @brief Constructs a list with the given contents of type T
- * @param init list of values that are, one by one, given to a constructor of T
- */
- template<class T>
- static tag_list of(std::initializer_list<T> init);
-
- /**
* @brief Constructs an empty list
*
* The content type is determined when the first tag is added.
@@ -152,10 +148,7 @@ public:
friend bool operator==(const tag_list& lhs, const tag_list& rhs);
friend bool operator!=(const tag_list& lhs, const tag_list& rhs);
-private:
- std::vector<value> tags;
- tag_type el_type_;
-
+protected:
/**
* Internally used initialization function that initializes the list with
* tags of type T, with the constructor arguments of each T given by il.
@@ -163,15 +156,25 @@ private:
*/
template<class T, class Arg>
void init(std::initializer_list<Arg> il);
+
+private:
+ std::vector<value> tags;
+ tag_type el_type_;
};
+/**
+ * @brief Subclass of tag_list with compile-time-known element type
+ * @todo Statically override some of the superclass methods to forgo dynamic type checking
+ */
template<class T>
-tag_list tag_list::of(std::initializer_list<T> il)
+class tag_list::of : public tag_list
{
- tag_list result;
- result.init<T, T>(il);
- return result;
-}
+public:
+ of(std::initializer_list<T> il)
+ {
+ init<T>(il);
+ }
+};
template<class T, class... Args>
void tag_list::emplace_back(Args&&... args)