Boost logo

Boost Users :

Subject: Re: [Boost-users] How to force a compile failure if a template parameter isn't floating-point
From: Eric Niebler (eric_at_[hidden])
Date: 2012-07-18 12:44:18


On 7/18/2012 4:02 AM, Maxime van Noppen wrote:
> But you might as well consider having:
>
> template <typename FPT>
> std::string f_impl(FPT v)
> {
> }
>
> std::string f(float v) { return f_impl(v); }
> std::string f(double v) { return f_impl(v); }

Don't forget long double. But +1 to the simple suggestion.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net