
#ifndef PLS_INTERNAL_DATA_STRUCTURES_OPTIONAL_H_
#define PLS_INTERNAL_DATA_STRUCTURES_OPTIONAL_H_

#include <utility>

#include "pls/internal/data_structures/delayed_initialization.h"

namespace pls {
namespace internal {
namespace data_structures {

template<typename T>
class optional {
 public:
  optional() = default;

  template<typename ...ARGS>
  explicit optional(ARGS &&...args): data_{std::forward<ARGS>(args)...} {}

  operator bool() const {
    return data_.initialized();
  }

  T &operator*() {
    return *data_;
  }

 private:
  delayed_initialization<T> data_;
};

}
}
}

#endif //PLS_INTERNAL_DATA_STRUCTURES_OPTIONAL_H_
