Printing shortest decimal form of floating point number with Mir

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Dec 24 09:56:50 UTC 2020


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);
};




More information about the Digitalmars-d-announce mailing list