libshit

Just some random shit
git clone https://git.neptards.moe/neptards/libshit.git
Log | Files | Refs | Submodules | README | LICENSE

base.hpp (1056B)


      1 #ifndef GUARD_IMMEMORIALLY_AROMATICK_GWEDUC_DESKS_7279
      2 #define GUARD_IMMEMORIALLY_AROMATICK_GWEDUC_DESKS_7279
      3 #pragma once
      4 
      5 #include "libshit/nonowning_string.hpp"
      6 #include "libshit/shared_ptr.hpp" // IWYU pragma: export
      7 #include "libshit/utils.hpp"
      8 
      9 #include <utility>
     10 
     11 namespace Libshit::Translate
     12 {
     13   class Node;
     14   class Translation;
     15   using TranslationPtr = NotNullSharedPtr<const Translation>;
     16 
     17   template <typename Base>
     18   class NodePtrBase : public Base
     19   {
     20   public:
     21     using Base::Base;
     22     template <typename T>
     23     NodePtrBase(const NodePtrBase<T>& b) : Base{b} {}
     24     template <typename T>
     25     NodePtrBase(NodePtrBase<T>&& b) : Base{Move(b)} {}
     26 
     27     decltype(auto) operator[](StringView key) const
     28     { return this->get()->operator[](key); }
     29 
     30     template <typename... Args>
     31     TranslationPtr operator()(Args&&... args) const
     32     { return this->get()->operator()(std::forward<Args>(args)...); }
     33   };
     34 
     35   using NotNullNodePtr = NodePtrBase<NotNullRefCountedPtr<const Node>>;
     36   using NodePtr = NodePtrBase<RefCountedPtr<const Node>>;
     37 }
     38 
     39 #endif