Templates args

Andrey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 14 12:27:14 PDT 2016


Hi guys!

Help a newbie please.

Playing with D and trying to understand some features.
Here is my try to carry out my code from C++ project to D

struct Sigmoid(T)
{
   const T Function(T value)
   {
    ...
   }
   const T DerivateFunction(const T value)
   {
    ...
   }
}

struct Neurons_layer(T = float, size_t neurons_num = 0, F = 
Sigmoid!T)
   if(isFloatingPoint!T && is(typeof(F.Function)))
     {
     private:
       static if(neurons_num > 0)
	T[neurons_num] _neurons_arr;
       else
	T[] _neurons_arr;

     private:
       alias Function = F.Function;
}

unittest
{
   Neurons_layer!(float,5,Sigmoid!float) nf;
}


The question is - How to make in pretty way this line:
  Neurons_layer!(float,5,Sigmoid!float) nf;




More information about the Digitalmars-d-learn mailing list