bkrueger / mocasinns

MOnte-CArlo-SImulations - Neat'N'Simple
Other
4 stars 1 forks source link

Use boost::type_traits to make some functions of steps optional. #27

Closed bkrueger closed 11 years ago

bkrueger commented 11 years ago

The functions StepType::is_executable() and StepType::selection_probability_factor() are in most cases unnecessary and can take the values true and 1.0.

Using boost::type_traits [1] one can check at compile-time in the respective algorithms using this functions (mainly Simulation::do_steps), whether these two functions are implemented by the user. If they are not, the standard values true or 1.0 can be used.

This reduces the amount of code a beginner has to write for his StepType and the amount of confusion a user has when using the library the first time.

[1] http://www.boost.org/doc/libs/1_53_0/libs/type_traits/doc/html/index.html

bkrueger commented 11 years ago

Possible ressources: http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence http://bytes.com/topic/c/answers/62065-member-function-existence-queries