00001
00002
00003 #ifndef DUNE_GMPFIELD_HH
00004 #define DUNE_GMPFIELD_HH
00005
00010 #include <iostream>
00011 #include <string>
00012
00013 #if HAVE_GMP || DOXYGEN
00014
00015 #include <gmpxx.h>
00016
00017 #include <dune/common/typetraits.hh>
00018
00019 namespace Dune
00020 {
00021
00026 template< unsigned int precision >
00027 class GMPField
00028 : public mpf_class
00029 {
00030 typedef mpf_class Base;
00031
00032 public:
00034 GMPField ()
00035 : Base(0,precision)
00036 {}
00037
00041 GMPField ( const char* str )
00042 : Base(str,precision)
00043 {}
00044
00048 GMPField ( const std::string& str )
00049 : Base(str,precision)
00050 {}
00051
00054 template< class T,
00055 typename EnableIf = typename std::enable_if<
00056 std::is_convertible<T, mpf_class>::value>::type
00057 >
00058 GMPField ( const T &v )
00059 : Base( v,precision )
00060 {}
00061
00062
00063 operator double () const
00064 {
00065 return this->get_d();
00066 }
00067
00068 };
00069
00070 template <unsigned int precision>
00071 struct IsNumber<GMPField<precision>>
00072 : public std::integral_constant<bool, true> {
00073 };
00074 }
00075
00076 #endif // HAVE_GMP
00077
00078 #endif // #ifndef DUNE_GMPFIELD_HH