[Glacier] Add a binary tree implementation.

Additionally add an optional class to return found values
in the tree. And a reference container (Ref) similar to
std::reference_wrapper to allow storing references in containers.
This commit is contained in:
Drew Galbraith 2023-11-03 19:46:27 -07:00
parent 26b61db021
commit 98f029ae23
4 changed files with 234 additions and 0 deletions

View file

@ -51,6 +51,8 @@ class RefPtr {
T* get() const { return ptr_; };
T& operator*() const { return *ptr_; }
T* operator->() const { return ptr_; }
bool empty() const { return ptr_ == nullptr; }
operator bool() const { return ptr_ != nullptr; }
bool operator==(decltype(nullptr)) const { return (ptr_ == nullptr); }

View file

@ -0,0 +1,18 @@
#pragma once
namespace glcr {
template <typename T>
class Ref {
public:
Ref(T& ref) : ref_(ref) {}
Ref(const Ref& other) = default;
Ref(Ref&& other) = default;
operator T&() const { return ref_; }
private:
T& ref_;
};
} // namespace glcr