If you need only floating points only, then what do you need template for? Make two overloaded versions of your routine: std::string f(float v) { ... } std::string f(double v) { ... } That's it :) -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Paul A. Bristow Sent: Wednesday, July 18, 2012 1:54 PM To: boost-users@lists.boost.org Subject: [Boost-users] How to force a compile failure if a template parameter isn't floating-point I have some functions that I want to ensure (with a compile failure - because it means a logical mistake) that they are not instantiated if the template parameter is not floating point type. In effect, #error Type Not floating point! template <typename FPT> std::string f(FPT v) { ... } At present I have added a run-time check, but doesn't prevent compilation (and instantiation). if (boost::is_floating_point<FPT>::value; == false) { assert fail or something and/or return " "Type Not floating point!"; } I don't see how enable_if can help either. I can't find BOOST_CONCEPT_ASSERT((boost::FloatingPoint<FPT>)); or boost::function_requires< boost::Integer<FPT> >(); Suggestions welcome :-) Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users