Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-03-01 08:12:56

>With no offense intended, but that's a very simple version which doesn't
>work in many situations. The problems of your solution are:
>- Doesn't work well for UDTs (try std::complex, some conversions are
> ambiguous then)

What rule of the language prohibit this conversion? My vc71 compiler can do
it, como and g++

>- Doesn't scale for new types (you need to know all of them in the
> single header that defines the constant)

You could add the overloads with eg a macro in your own header. What should
hinder this?

>- Doesn't work for more complex expressions (pi*pi*t instead of T(pi)*pi*t)

true, but what precision does pi*pi have? IMO, it's good to have that
information in the code.

>- Doesn't work for function calls (srqt(pi)*t instead of sqrt(T(pi))*t)

again it a matter of being explicit about which overloaded version you want
to call;
therefore one would always add T().

>- Doesn't solve the naming dilemma (how to spell the constant "pi*pi"?)

is pi_square that bad?

>- Doesn't work well with unit libraries AFAICS (again not scaling well)


>I really suggest you look at my code at
><>, which solves
>all of the above points. Feel free to ask questions.

Is there any documentation?

>From your example file:

std::cout << pi.get< float >() << std::endl;

which is float( pi ) spelt more elaborate.

std::cout << pi + pi - pi * pi / pi + d << std::endl;

how often does such an expression occur in practice? Afterall, a single pi
would do.

std::cout << sqrt( sqrt( two + pi ) ) + d << std::endl;

will everything left of d be a constant? If so, what would the point be?



Boost list run by bdawes at, gregod at, cpdaniel at, john at