diff --git a/common/test/.gitignore b/common/test/.gitignore index 0278df68c7a159efc8677c8e1d34cf89a4c0737f..ef09bb477acb8cb457f16d6bf2ddd2f4ad1eab16 100644 --- a/common/test/.gitignore +++ b/common/test/.gitignore @@ -40,3 +40,4 @@ testfassign2 testfassign3 testfassign4 smallobject +conversiontest diff --git a/common/test/Makefile.am b/common/test/Makefile.am index 897c7a2c092a119fff94ba96d44e328636167e75..65fe81ac89ba513bd85a567c08d145aa8a18c9fb 100644 --- a/common/test/Makefile.am +++ b/common/test/Makefile.am @@ -9,7 +9,8 @@ TESTPROGS = parsetest test-stack arraylisttest smartpointertest \ testfassign1 testfassign2 testfassign3 \ testfassign4 \ testfassign_fail1 testfassign_fail2 testfassign_fail3 \ - testfassign_fail4 testfassign_fail5 testfassign_fail6 + testfassign_fail4 testfassign_fail5 testfassign_fail6 \ + conversiontest # which tests to run COMPILE_XFAIL=$(DUNE_COMMON_ROOT)/bin/xfail-compile-tests @@ -122,6 +123,8 @@ testfassign_fail5_CPPFLAGS = $(AM_CPPFLAGS) -D_N=2 -D_M=2 -D_VALUES="1, 2" testfassign_fail6_SOURCES = testfassign.cc testfassign_fail6_CPPFLAGS = $(AM_CPPFLAGS) -D_N=2 -D_M=2 -D_VALUES="1, 2, nextRow, 2, 3, nextRow, 4, 5" +conversiontest_SOURCES = conversiontest.cc + sourcescheck_NOSOURCES = exprtmpl.cc timing.cc include $(top_srcdir)/am/global-rules diff --git a/common/test/conversiontest.cc b/common/test/conversiontest.cc new file mode 100644 index 0000000000000000000000000000000000000000..76d15cf98f77888b231ff858ca77a67650255018 --- /dev/null +++ b/common/test/conversiontest.cc @@ -0,0 +1,12 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#include <iostream> +#include <dune/common/typetraits.hh> + +int main () +{ + std :: cout << "Conversion from int to double exists? " + << Dune::Conversion< int, double > :: exists << std :: endl; + + return 0; +} diff --git a/common/typetraits.hh b/common/typetraits.hh index 6ec65ebce0e263185aab32016efb998095d6f473..bfd2207288d8ca1b45e83acda69909d7c94d97b0 100644 --- a/common/typetraits.hh +++ b/common/typetraits.hh @@ -218,6 +218,17 @@ namespace Dune }; }; + template<> + class Conversion< int, double > + { + public: + enum { + exists = true, + isTwoWay = false, + sameType = false + }; + }; + template<class T> class Conversion<T,T>{ public: