diff options
| author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-04-01 14:21:10 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-04-01 14:21:10 +0100 |
| commit | 6635cee143eb4cf3882bac519b8c12b83b62de62 (patch) | |
| tree | 6ec80724a1d622b6933de8afa27cbafba2110471 /lib/util.h | |
| parent | Helper to instantiate transient static values as required (diff) | |
| download | ilt-6635cee143eb4cf3882bac519b8c12b83b62de62.tar.bz2 ilt-6635cee143eb4cf3882bac519b8c12b83b62de62.tar.xz ilt-6635cee143eb4cf3882bac519b8c12b83b62de62.zip | |
Add helper to Decompose a member pointer
Diffstat (limited to 'lib/util.h')
| -rw-r--r-- | lib/util.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -35,6 +35,16 @@ inline constexpr auto GetFirst = Nth<0>; inline constexpr auto GetSecond = Nth<1>; inline constexpr auto GetSwapped = Nth<0, 1>; +template<typename T, typename M> struct Decompose { + consteval Decompose(M T::*) { } + + using ValueType = M; + using ContainerType = T; +}; + +template<auto MbrPtr> using MemberValueType = typename decltype(Decompose {MbrPtr})::ValueType; +template<auto MbrPtr> using ContainerType = typename decltype(Decompose {MbrPtr})::ContainerType; + template<typename T> bool createIfRequired(std::shared_ptr<T> & instance, std::weak_ptr<T> & common) |
