From 5a0b3927a33807cca4c77c40eb873f8a3b51b0b0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 29 Apr 2023 19:07:11 +0100 Subject: Drop .hpp for header only things Half of them acquired a .cpp part anyway --- lib/stdTypeDefs.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/stdTypeDefs.h (limited to 'lib/stdTypeDefs.h') diff --git a/lib/stdTypeDefs.h b/lib/stdTypeDefs.h new file mode 100644 index 0000000..317cdb3 --- /dev/null +++ b/lib/stdTypeDefs.h @@ -0,0 +1,45 @@ +#pragma once + +#include +#include + +template struct AnyPtr { + // cppcheck-suppress noExplicitConstructor + AnyPtr(T * p) : ptr {p} { } + // cppcheck-suppress noExplicitConstructor + template AnyPtr(const S & p) : ptr {p.get()} { } + auto + get() const + { + return ptr; + } + auto + operator->() const + { + return ptr; + } + auto & + operator*() const + { + return *ptr; + } + +private: + T * ptr; +}; + +template struct StdTypeDefs { + using AnyPtr = ::AnyPtr; + using AnyCPtr = ::AnyPtr; + using Ptr = std::shared_ptr; + using CPtr = std::shared_ptr; + using WPtr = std::weak_ptr; + using Collection = std::vector; + using CCollection = std::vector; + using WCollection = std::vector; +}; + +template struct ConstTypeDefs { + using Ptr = std::shared_ptr; + using Collection = std::vector; +}; -- cgit v1.2.3