aboutsummaryrefslogtreecommitdiff
path: root/build/utility
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-27 12:57:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-27 12:57:39 +0200
commit9d818423031083f227a5e872826ed8c2d6e14a0f (patch)
tree794f3a27ba27e9210dc0c891fe681b863b53c747 /build/utility
parent10cdf9fdcd4181f2ea3dec1abf5bcc359b87829c (diff)
Add support for specifying library link order
Diffstat (limited to 'build/utility')
-rw-r--r--build/utility29
1 files changed, 29 insertions, 0 deletions
diff --git a/build/utility b/build/utility
index 01ecd95..064a95f 100644
--- a/build/utility
+++ b/build/utility
@@ -38,6 +38,35 @@ namespace build
bool operator() (const P& x, const P& y) const {return *x < *y;}
};
+ // Simple optional class template while waiting for std::optional.
+ //
+ template <typename T>
+ class optional
+ {
+ public:
+ typedef T value_type;
+
+ optional (): null_ (true) {}
+ optional (const T& v): value_ (v), null_ (false) {}
+ optional& operator= (const T& v) {value_ = v; null_ = false; return *this;}
+
+ T& value () {return value_;}
+ const T& value () const {return value_;}
+
+ T* operator-> () {return &value_;}
+ const T* operator-> () const {return &value_;}
+
+ T& operator* () {return value_;}
+ const T& operator* () const {return value_;}
+
+ explicit operator bool () const {return !null_;}
+
+ private:
+ T value_;
+ bool null_;
+ };
+
+
// Support for reverse iteration using range-based for-loop:
//
// for (... : reverse_iterate (x)) ...