Template specialisation for range of types
data pulverizer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Mar 12 14:12:13 PDT 2017
On Sunday, 12 March 2017 at 20:15:43 UTC, Meta wrote:
> auto max(T: const U, U)(T* x, T* y) <----- Changed `ConstOf!U`
> to `const U`
> {
> writeln("Const template");
> return *x > *y ? x : y;
> }
How detailed can I be about the template specialisation? From
example in the book "C++ the complete guide" we can have:
/* pointer const reference */
template<typename T>
inline T* const& max(T* const& a, T* const&b)
{
return a* < b* ? b : a;
}
/* const reference const pointer */
template<typename T>
inline T const* const& max(T* const* const& a, T* const* const& b)
{
...;
}
What would be the equivalent in D?
More information about the Digitalmars-d-learn
mailing list