Remove input.hpp

This commit is contained in:
ArthurSonzogni
2021-07-10 12:29:39 +02:00
committed by Arthur Sonzogni
parent 7ee6edfd1f
commit 26db8228f9
16 changed files with 240 additions and 252 deletions

View File

@@ -6,7 +6,7 @@
namespace ftxui {
/// @brief An adapter. Own or reference a constant object.
/// @brief An adapter. Own or reference an immutable object.
template <typename T>
class ConstRef {
public:
@@ -14,6 +14,7 @@ class ConstRef {
ConstRef(T t) : owned_(t) {}
ConstRef(const T* t) : address_(t) {}
const T& operator*() { return address_ ? *address_ : owned_; }
const T& operator()() { return address_ ? *address_ : owned_; }
const T* operator->() { return address_ ? address_ : &owned_; }
private:
@@ -21,6 +22,22 @@ class ConstRef {
const T* address_ = nullptr;
};
/// @brief An adapter. Own or reference an mutable object.
template <typename T>
class Ref{
public:
Ref() {}
Ref(T t) : owned_(t) {}
Ref(T* t) : address_(t) {}
T& operator*() { return address_ ? *address_ : owned_; }
T& operator()() { return address_ ? *address_ : owned_; }
T* operator->() { return address_ ? address_ : &owned_; }
private:
T owned_;
T* address_ = nullptr;
};
/// @brief An adapter. Own or reference a constant string. For convenience, this
/// class convert multiple mutable string toward a shared representation.
class StringRef {