diff --git a/library/include/larra/impl/public_cast.hpp b/library/include/larra/impl/public_cast.hpp new file mode 100644 index 0000000..111909a --- /dev/null +++ b/library/include/larra/impl/public_cast.hpp @@ -0,0 +1,34 @@ +#pragma once +#include +#include + +namespace larra::xmpp::impl { + +template +struct PublicCastTag { + friend constexpr auto MagicGetPrivateMember(PublicCastTag); +}; + +template +struct PublicCast {}; + +template +struct PublicCast { + friend constexpr auto MagicGetPrivateMember(PublicCastTag) { + return ptr; + } +}; + +template +struct PublicCast { + friend constexpr auto MagicGetPrivateMember(PublicCastTag) { + return ptr; + } +}; + +template +constexpr auto GetPrivateMember(const T&) { + return MagicGetPrivateMember(PublicCastTag, I>{}); +}; + +} // namespace larra::xmpp::impl diff --git a/library/include/larra/utils.hpp b/library/include/larra/utils.hpp index bca4277..1141b7b 100644 --- a/library/include/larra/utils.hpp +++ b/library/include/larra/utils.hpp @@ -83,9 +83,9 @@ struct FieldsDescription { * \param value new value for field * \return an object of type std::decay_t with data from T with fields from \ref self and the \ref value of the field \ref ptr */ - template // NOLINTNEXTLINE - constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const -> std::decay_t - requires(std::is_constructible_v...> && std::constructible_from, T> && + template + constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const + requires(std::is_constructible_v...> && std::is_constructible_v, T> && std::is_constructible_v && impl::SetConcept) { return std::decay_t{utempl::Unpack(this->tuple, [&](auto... fs) -> T {