Printing shortest decimal form of floating point number with Mir
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Thu Dec 24 11:05:16 UTC 2020
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>);
More information about the Digitalmars-d-announce
mailing list