Chain two different struct specialization
Andrea Fontana
nospam at example.com
Fri Mar 1 06:32:10 PST 2013
On Friday, 1 March 2013 at 14:27:40 UTC, Andrea Fontana wrote:
> I'm trying to do something like this. I don't know whether or
> not it's a good idea, i'm open to solutions and suggestions
>
> struct MyStruct(WEIGHTS)
> {
> string ...
> string ...
>
> alias WEIGHTS weights;
> }
>
> double likeness(T,T1)(ref in T1, ref in T2)
> {
> // Here i do some complex calculus using struct fields
> // and using weights consts
> }
>
> enum FirstWeights : double
> {
>
> }
Ops. Here the complete message:
I'm trying to do something like this. I don't know whether or not
it's a good idea, i'm open to solutions and suggestions
struct MyStruct(WEIGHTS)
{
string ...
string ...
alias WEIGHTS weights;
}
double likeness(T,T1)(ref in T1, ref in T2)
{
// Here i do some complex calculus using struct fields
// and using weights consts
}
enum FirstWeights : double
{
double foo = 0.3,
double bar = 0.4
}
enum SecondWeights : double
{
double foo = 0.3,
double bar = 0.4
}
so:
auto s1 = MyStruct!FirstWeights ...
auto s2 = MyStruct!SecondWeights ...
likeness(s1,s2); // works
But I can't mix different type (s1,s2) on a single range or
array, to check for likeness, is there a way? (or should I avoid
template init a double[] weights field)
More information about the Digitalmars-d-learn
mailing list