Skip to content

Instantly share code, notes, and snippets.

@Tomcc
Created January 31, 2016 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tomcc/355b7ecde550a1d6f678 to your computer and use it in GitHub Desktop.
Save Tomcc/355b7ecde550a1d6f678 to your computer and use it in GitHub Desktop.
template<typename T>
class const_optional {
public:
optional(); //invalid constructor
optional(const T& obj); //valid constructor
const T& unwrap() const;
operator bool() const;
};
template<typename T>
class optional {
public:
optional(); //invalid constructor
optional(T& obj); //valid constructor
T& unwrap();
const T& unwrap() const;
const_optional<T> as_const() const;
operator bool() const;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment