diff --git a/types.hpp b/types.hpp
index 6e74ec45..fcfb027c 100644
--- a/types.hpp
+++ b/types.hpp
@@ -14,18 +14,18 @@
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
- * Copyright 2011 Danny Robson
+ * Copyright 2011-2014 Danny Robson
*/
#ifndef __UTIL_TYPES_HPP
#define __UTIL_TYPES_HPP
-#include "platform.hpp"
-
#include
#include
#include
+#include
+//-----------------------------------------------------------------------------
/// Returns the number of elements of a statically allocated array
template
constexpr size_t elems(const T (&)[N])
@@ -38,4 +38,24 @@ make_unique(Args&&... args) {
return std::unique_ptr (new T(std::forward(args)...));
}
+
+//-----------------------------------------------------------------------------
+template
+T
+first (T a) {
+ if (a)
+ return a;
+
+ throw std::logic_error ("no valid object");
+}
+
+template
+T
+first (T a, Args&& ...b) {
+ if (a)
+ return a;
+
+ return first (std::forward(b)...);
+}
+
#endif