// // Created by Patrick Maschek on 22.01.2024. // #ifndef CONST_CONTAINER_COMPILEOPTIONAL_H_ #define CONST_CONTAINER_COMPILEOPTIONAL_H_ #include #include namespace cc { template class CompileOptional {}; template class CompileOptional { public: using defined = std::false_type; using value_type = T; constexpr CompileOptional() = default; constexpr CompileOptional(const value_type& value) {} template constexpr CompileOptional(Args... args) {} }; template class CompileOptional { public: using defined = std::true_type; using value_type = T; constexpr CompileOptional() = default; constexpr CompileOptional(const value_type& value) : _value(value) {} constexpr CompileOptional(value_type&& value) : _value(value) {} template constexpr CompileOptional(Args... args) : _value( { std::forward(args)... } ) {} constexpr operator T&() { return _value; } private: T _value; }; } #endif //CONST_CONTAINER_COMPILEOPTIONAL_H_