static functions associated with enums

2013-03-21 Thread Dan
I have an enum, say: enum AssetCategory { Investment, PrimaryResidence, FamilyProperty, FinancialInstrument } and I have functions that convert to/from strings to be used in Json (via vibe json). The vibe wants to call out to user supplied toJson/fromJson if both functions are provided

Re: static functions associated with enums

2013-03-21 Thread Ali Çehreli
On 03/21/2013 01:34 PM, Dan wrote: > Json serializeToJson(T)(T value) { > ... > static if( __traits(compiles, value = T.fromJson(value.toJson())) ){ It looks like fromJson must be a static member function because the condition is written in a way that fromJson is called on the type itself. (I