On Wednesday, 23 December 2020 at 20:56:26 UTC, jmh530 wrote:
doing similar things). Abusing C++'s syntax you might have something like
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++.

I don't use concepts yet as it is a very new C++ feature. The following code does not work in XCode, although it probably should according to cppreference. So take this with a grain of salt (other variations should be possible):

namespace detail {
  template<template<typename> typename F, class U>
  constexpr void _is_instantiable(F<U> a){}
}

template<class T>
struct Foo{};

template<class T>
concept Fooish = requires(T a){
    detail::_is_instantiable<Foo>(a);
};


              • ... 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
              • ... welkam via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... welkam 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