bkrueger / mocasinns

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

Tests do not compile because of C++11 usage in test classes #28

Closed SpeckFleck closed 11 years ago

SpeckFleck commented 11 years ago

g++ -g -pg -O2 -Wall -Wextra -pedantic -std=c++0x -fopenmp -I../include -I../../libising/src -I../../librandom/include -o test.o -c test.cpp In file included from test_metropolis.hpp:13, from test.cpp:16: ../include/mocasinns/metropolis.hpp:37: error: ‘nullptr’ was not declared in this scope ../include/mocasinns/metropolis.hpp:37: error: ‘nullptr’ was not declared in this scope

SpeckFleck commented 11 years ago

Official workaround: http://stackoverflow.com/questions/2419800/can-nullptr-be-emulated-in-gcc

Combine with compiler switch. Keep older gcc support in first version. Proposal: support for gcc < 4.7 to be abandoned in near feature (after THE BIG UPGRADE™).

bkrueger commented 11 years ago

It should be no problem to support the old compilers even longer.

The problem is that it was not documented that the default-template-argument cannot be used with older versions of the gcc-compiler. The code with the user-provided observables does work for older versions of gcc. I consider implementing the workaround you suggested.

I usually provide all functions and classes according to the old C++99 standard. If it is possible to have a more user friendly version with C++11 (e.g. this. standard template argument for observing the energy), I provide this as an option instead of the standard version.

The problems are then the tests: We should think about which version of gcc to use for the tests, because on the one hand it would be nice for every user to compile the tests, on the other hand the features exclusivly available in newer compiler versions should be tested, too.

SpeckFleck commented 11 years ago

Fixed by commit cbf7d58

bkrueger commented 11 years ago

Altered the solution of the bug by using boost::type_traits.

Advantages:

Ressources: [1] http://stackoverflow.com/questions/2005794/extract-the-return-type-of-a-function-without-calling-it-using-templates [2] http://stackoverflow.com/questions/2165030/use-boost-to-get-arity-and-paramerter-types-of-member-function-boostfunction