Skip to content

Commit

Permalink
add operator* and a static assert against reference types
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisOSRM committed Aug 27, 2014
1 parent 9badbd0 commit 1141292
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace mapbox { namespace util {

template<typename T>
class optional {
static_assert(!std::is_reference<T>::value, "optional doesn't support references");

variant<none_t, T> variant_;

public:
Expand All @@ -40,6 +42,10 @@ namespace mapbox { namespace util {
return variant_.template get<T>();
}

T const& operator *() const { return this->get() ; }
T operator *() { return this->get() ; }


optional& operator = ( T const& v ) {
variant_ = v;
return *this;
Expand Down

0 comments on commit 1141292

Please sign in to comment.