re: Boost.Random patch for gcc-3.4.1

On Tuesday 13 July 2004 09:17, Synge Todo <wistaria@comp-phys.org> wrote:
I'm sending a small patch for Boost.Random to compile by using gcc-3.4.1 (on Linux Fedora Core 2). Could somebody apply this patch? Thank you in advance.
The patches add #include<cmath> to a couple of the Random headers. This is I assume to provide std::pow definitions for builtin types. In this situation this is wrong. The Random headers are totally generic and can be used on a variety of numeric types. Not necessarily the builtin float etc. It is the user's responsibility to make sure that a 'pow' is defined for the specific type used. Random will find such definition in namespace std or with type dependant (Konig) lookup. This is hard on the user, but make the code generic and with the minmum of dependencies. Michael

From: Michael Stevens <Michael.Stevens@epost.de> Date: Sat, 17 Jul 2004 15:51:47 +0200
The patches add #include<cmath> to a couple of the Random headers. This is I assume to provide std::pow definitions for builtin types.
Yes.
In this situation this is wrong. The Random headers are totally generic and can be used on a variety of numeric types. Not necessarily the builtin float etc. It is the user's responsibility to make sure that a 'pow' is defined for the specific type used. Random will find such definition in namespace std or with type dependant (Konig) lookup.
I am a bit confused. Can "using std::pow;" be accepted by the compilers without a declaration of std::pow? Synge Todo wistaria@comp-phys.org

Synge Todo <wistaria@comp-phys.org> writes:
From: Michael Stevens <Michael.Stevens@epost.de> Date: Sat, 17 Jul 2004 15:51:47 +0200
The patches add #include<cmath> to a couple of the Random headers. This is I assume to provide std::pow definitions for builtin types.
Yes.
In this situation this is wrong. The Random headers are totally generic and can be used on a variety of numeric types. Not necessarily the builtin float etc. It is the user's responsibility to make sure that a 'pow' is defined for the specific type used. Random will find such definition in namespace std or with type dependant (Konig) lookup.
I am a bit confused. Can "using std::pow;" be accepted by the compilers without a declaration of std::pow?
No it can't. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

From: David Abrahams <dave@boost-consulting.com> Date: Wed, 21 Jul 2004 07:20:20 -0400
I am a bit confused. Can "using std::pow;" be accepted by the compilers without a declaration of std::pow?
No it can't.
Thank you, David. It means that we have to always include <cmath> beforehand whenever we include Boost.Random headers, since it contains a line declaring "using std:pow;". This applies even if we just include Boost.Random headers without any instantiation of Boost.Random class templates. Isn't this requirement too strong for users??? Synge

Synge Todo <wistaria@comp-phys.org> writes:
From: David Abrahams <dave@boost-consulting.com> Date: Wed, 21 Jul 2004 07:20:20 -0400
I am a bit confused. Can "using std::pow;" be accepted by the compilers without a declaration of std::pow?
No it can't.
Thank you, David. It means that we have to always include <cmath> beforehand whenever we include Boost.Random headers, since it contains a line declaring "using std:pow;". This applies even if we just include Boost.Random headers without any instantiation of Boost.Random class templates. Isn't this requirement too strong for users???
Yes. Boost.Random should #include <cmath> itself. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

Le mer 21/07/2004 à 14:25, Synge Todo a écrit :
From: David Abrahams <dave@boost-consulting.com> Date: Wed, 21 Jul 2004 07:20:20 -0400
I am a bit confused. Can "using std::pow;" be accepted by the compilers without a declaration of std::pow?
No it can't.
Thank you, David. It means that we have to always include <cmath> beforehand whenever we include Boost.Random headers, since it contains a line declaring "using std:pow;". This applies even if we just include Boost.Random headers without any instantiation of Boost.Random class templates. Isn't this requirement too strong for users???
No, I would say it means Boost.Random should include <cmath>. It's what you were suggesting at first (I think it was you). It's also what the other Boost libraries do (at least the Interval library does it). Regards, Guillaume
participants (4)
-
David Abrahams
-
Guillaume Melquiond
-
Michael Stevens
-
Synge Todo