These are chat archives for boostorg/hana

15th
Mar 2016
Barrett Adair
@badair
Mar 15 2016 23:35
Awesome. I'll definitely use it on my projects. It's so hard to benchmark compile time performance. Today I wrote a metafunction that I thought you might want to add to hana (or perhaps a modified version). I call it decorate_like. You give it two types, Model and Target. It it recursively peels off pointers, member pointers, references, and cv qualifiers of Model (with special cases for std smart pointers and reference_wrapper). On the way back down, it dresses up Target in the same way. For a COMPLETELY contrived example, here's one of my test cases:
        struct foo {};
        using model = volatile std::reference_wrapper<std::unique_ptr<void(foo::* const)(int)>>;
        using target = void(int, int);
        using result = decorate_like<model, target>;
        using check = std::is_same<
            result,
            volatile std::reference_wrapper<std::unique_ptr<void(foo::* const)(int, int)>>
        >;

        static_assert(check{}, "");
Here's a less contrived example:
        using T = decorate_like<const int*, float>;
        using result = std::is_same<const float*, T>;
        static_assert(result{}, "");
Anyway, I'll assume that you don't want it. I may use it internally for my callable_traits project, but it doesn't fit as part of the public interface for that. So I thought I'd throw it out there