On Wednesday, 23 December 2020 at 20:56:26 UTC, jmh530 wrote:
concept Bar(T) = requires(U)() {
    Foo!U; //akin to something like typename T::Foo<U>;
}
where we would basically be telling the compiler that T has to be a Foo!U, which would mean you would have to use Bar like Bar!U...at least that's the idea. I don't think anything like this would work currently in C++.

Non-concept version is more verbose, but yeah, works fine in C++17:

namespace detail {
    template<template<typename> class F, class U>
    static constexpr void _dummy(const F<U> &a);

    template<class T, template<typename> typename F, class=void>
    struct has_outer_template : std::false_type {};

    template<class T, template<typename> typename F>
struct has_outer_template<T,F,std::void_t<decltype(_dummy<F>(std::declval<T&>()))>>: std::true_type {};
};

template <class T, template<typename> typename F>
inline constexpr bool has_outer_template = detail::has_outer_template<T,F>::value;

template<class T>
struct Foo{};

static_assert(has_outer_template<Foo<int>,Foo>);

              • ... 9il via Digitalmars-d-announce
              • ... aberba via Digitalmars-d-announce
              • ... jmh530 via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... jmh530 via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... 9il via Digitalmars-d-announce
  • Re: Printing shortest deci... James Blachly via Digitalmars-d-announce

Reply via email to