Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for logging various templated classes #155

Open
andrewkcorcoran opened this issue Oct 4, 2022 · 5 comments
Open

Support for logging various templated classes #155

andrewkcorcoran opened this issue Oct 4, 2022 · 5 comments

Comments

@andrewkcorcoran
Copy link

andrewkcorcoran commented Oct 4, 2022

Such as below. If you control the classes you can have workarounds but if you want to log a class owned by non user code something more is required.

struct Base1{};

template<typename T>
struct Base2 : public Base1
{
    T t;
};

template<typename T, typename S>
struct Derived : public Base2<T>
{
    S s;

   struct Nested{} nested;

   template<typename U>
   struct Nested2{};
};

auto n = Derived<int, double>::Nested2<unsigned int>{};
@andrewkcorcoran andrewkcorcoran changed the title Support for logging templated derived classes Support for logging various templated classes Oct 4, 2022
@erenon
Copy link
Contributor

erenon commented Jan 2, 2023

The closest I got is:

template <typename C>
using ThirdPartyNested = typename third_party::Derived<int, double>::template Nested2<C>;
BINLOG_ADAPT_TEMPLATE((typename C), (ThirdPartyNested<C>))

I'm unable to create a specialization (for CustomTag/CustomSerializer) for a nested template of a template:

error: template parameters not deducible in partial specialization

@andrewkcorcoran
Copy link
Author

In an ideal situation it would be great to be able to adapt without having to know the template specialisations
e.g. Derived<T, S>::Nested2<U> instead of Derived<int, double>::Nested2<unsigned int>

@andrewkcorcoran
Copy link
Author

andrewkcorcoran commented Jan 6, 2023

Also we might want to add a requirement to support nested concepts e.g.

template<SomeConcept T>
struct S
{
   struct S2{};

   template<typename U>
   concept C = requires(U u)
   {...};
};

BINLOG_ADAPT(S<T>);
BINLOG_ADAPT(S<T>::S2);
BINLOG_ADAPT(S<T>::C<U>);

@erenon
Copy link
Contributor

erenon commented Jan 24, 2023

Would you be interested in a solution (based on ADL) that requires adding a symbol to the namespace of the type that is being made loggable? Perhaps we can create something like:

namespace lib {

template<SomeConcept T>
struct S
{
   struct S2{};

   template<typename U>
   concept C = requires(U u)
   {...};
};

template <SomeConcept T, typename U>
void binlog_serializer(S<T>::C<U>) -> SomeSerializer<S<T>::C<U>>;
// ^^^-- this could be produced by a macro

} // namespace lib

(Also a question for #153)

@andrewkcorcoran
Copy link
Author

Yea I think that would work for our case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants