
Following small program does not give the expected result. It prints some big negative value if compiled with my gcc 3.4.3 on linux or intel-linux 8.1. However commenting out either (one suffices) of the commented out lines makes it work correctly. I don't understand what is happening here, can anybody what is wrong with this function 'convert' or is the use of the conversion library wrong? <code> #include <boost/numeric/conversion/cast.hpp> #include <iostream> template<typename Target, typename Source> inline typename ::boost::numeric::converter<Target,Source>::result_type //convert ( const Source& arg ) // using this signatures makes it work convert ( Source arg ) { return ::boost::numeric::converter< Target, Source >::convert( arg ) ; } // { Target temp = ::boost::numeric::converter< Target, Source
::convert( arg ) ; return temp ; }
int main() { int big = 900 ; ptrdiff_t diff = 16 ; std::cout << std::min( big, convert< int >( diff ) ) << std::endl ; return 0 ; } </code>