added defined to CompileOptional

This commit is contained in:
cyborg1811m 2024-01-22 23:28:47 +01:00
parent 8170507158
commit e8fac3a44d
1 changed files with 14 additions and 4 deletions

View File

@ -5,17 +5,27 @@
#ifndef CONST_CONTAINER_COMPILEOPTIONAL_H_
#define CONST_CONTAINER_COMPILEOPTIONAL_H_
#include <type_traits>
namespace cc {
template<typename, bool = false>
template<typename, bool Cond = false>
class CompileOptional {};
template<typename T>
class CompileOptional<T, false> {
public:
using defined = std::false_type;
};
template<typename T>
class CompileOptional<T, true> {
public:
using defined = std::true_type;
operator T&() { return _data; }
private:
T _data;
public:
operator T&() { return _data; }
};
}
#endif //UDIFF_COMPILEOPTIONAL_H_
#endif //CONST_CONTAINER_COMPILEOPTIONAL_H_