Boost logo

Boost :

From: Jens Maurer (jmaurer_at_[hidden])
Date: 2000-04-28 17:21:35


John Maddock wrote:
> Um, oops, yes the workarounds are for C++ Builder 4, I didn't try with
> version 5 and now that I have I wish I hadn't :-(

What's the value of __BORLANDC__ for C++ Builder 4?
We need to augment its config.hpp section with the version number.

> I'll try and figure out something better for builder 5, but it may prove to
> be impossible.

I think it's ok to have a different set of workarounds
(i.e. a possibly disjoint set of BOOST_NO_XXX defines)
for different compiler versions.

Btw, I've updated my BCC bug list with these new and depressing
entries:

[function address] Resolving addresses of
overloaded functions

Addresses of overloaded functions are not in all contexts
properly resolved (std:13.4 [over.over]); here is a small
example:

template<class Arg>
void f( void(*g)(Arg) );

void h(int);
void h(double);

template<class T>
void h2(T);

int main()
{
  void (*p)(int) = h; // this works (std:13.4-1.1)
  void (*p2)(unsigned char) = h2; // this works as well (std:13.4-1.1)
  f<int>(h2); // this also works (std:13.4-1.3)

  // "Cannot generate template specialization from h(int)",
  // "Could not find a match for f<Arg>(void (*)(int))"
  f<double>(h); // should work (std:13.4-1.3)

  f( (void(*)(double))h); // C-style cast works (std:13.4-1.6 with 5.4)

  // "Overloaded 'h' ambiguous in this context"
  f(static_cast<void(*)(double)>(h)); // should work (std:13.4-1.6 with 5.2.9)
}

Workaround: Always use C-style casts when determining
addresses of (potentially) overloaded functions.

[string conversion] Converting const char * to std::string

Implicitly converting const char * parameters to
std::string arguments fails if template functions are
explicitly instantiated (it works in the usual cases, though):

#include <string>

template<class T>
void f(const std::string & s)
{}

int main()
{
  f<double>("hello"); // "Could not find a match for f<T>(char *)"
}

Workaround: Use an explicit conversion to std::string
or declare the template function as taking a const char *
parameter in these rare cases.

[template value defaults] Dependent default
arguments for template value parameters

Template value parameters which default to an expression
dependent on previous template parameters don't work:

template<class T>
struct A
{
  static const bool value = true;
};

// "Templates must be classes or functions", "Declaration syntax error"
template<class T, bool v = A::value>
struct B {};

int main()
{
  B<int> x;
}

[cmath.abs] Function double std::abs(double) missing

The function double std::abs(double) should be
defined (std:26.5-5 [lib.c.math]), but it is not:

#include <cmath>

int main()
{
  double (*p)(double) = std::abs; // error
}

Note that int std::abs(int) will be used without
warning if you write std::abs(5.1).

Similar remarks apply to seemingly all of the other standard
math functions, where Borland C++ fails to provide float
and long double overloads.

Workaround: Use std::fabs instead if type genericity is
not required.

Jens Maurer.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk