- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I think I found a bug on Intel C++ 14 Compiler.
To hide complexity and reduce code quantity I hide my type trait behind a Preprocessor Function like this:
template < DistributionType eDistribution, typename Type, typename ParamType = Core::VoidType > struct DistributionTrait { typedef std::false_type DistributionType; };
With Preprocessor Function:
#define CreateDistribution( E, D, T, PT ) template <> \ struct DistributionTrait< E, T, PT > \ { \ typedef D DistributionType; \ }
I use it like that:
CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< u8 >, u8, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< u16 >, u16, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< u32 >, u32, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< u64 >, u64, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< s8 >, s8, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< s16 >, s16, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< s32 >, s32, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_int_distribution< s64 >, s64, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_real_distribution< f32 >, f32, Core::VoidType ); CreateDistribution( DistributionType::Uniform, std::uniform_real_distribution< f64 >, f64, Core::VoidType );
But when have more parameters when the bug occur:
CreateDistribution( DistributionType::Poisson, std::poisson_distribution< u8, f32 >, u8, f32 );
I have an error:
2>..\Math/Random/DistributionTrait.h(49): error : expected an identifier
2> CreateDistribution( DistributionType::Poisson, std::poisson_distribution< u8, f32 >, u8, f32 );
2> ^
I think in this case the compiler do not parse correctly the "Preprocessor Function", I think that is done with a sString.Split( ',' ).
Because when I use only the first parameter:
CreateDistribution( DistributionType::Poisson, std::poisson_distribution< u8 >, u8, f32 );
Or If I hide the type behind a typedef:
typedef std::poisson_distribution< u8 > PoissonU8F32; CreateDistribution( DistributionType::Poisson, PoissonU8F32, u8, f32 );
That work correctly.
I have a workaround, so is not a blocking issue, but this post is just a "bug-report".
Regards
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another way to use it:
#define BinomialDef( A, B ) binomial_distribution< A, B > CreateDistribution( Binomial, BinomialDef( u8, f32 ), u8, f32 );
The theory of splitString( ',' ); is wrong. It is a specific issue with template parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see the same behaviour with the Microsoft and the GNU compilers. I do not think this is a bug. The preprocessor has no special knowledge of template syntax.
See:
http://stackoverflow.com/questions/4295890/trouble-with-template-parameters-used-in-macros
Judy

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page