En réponse à Beman Dawes <[EMAIL PROTECTED]>:

> Current GCC and Intel compilers don't appear to allow using declarations
> at function scope, according to a bug report.

What do you call "current"? As far as I know, only gcc 2.95 suffers from this
bug (bug-report #1981 in gcc database), gcc 3.x and intel (on linux) correctly
handle using declarations at function scope. I can tell because in the interval
library, there is a workaround (using declaration at namespace scope) only
activated with gcc 2.95.

> Is there any reason not to just move the using declarations to namespace
> scope?
> 
> Answering my own queston, I think prefer the solution used in other
> boost code where calls to say std::abs are explicitly qualified, and ifdef 
> BOOST_NO_STDC_NAMESPACE then namespace std { using ::abs; } is
> supplied.
> 
> What are the pros and cons of the different approaches?

If the purpose is to access a std:: function, I don't think there is much of a
difference between the two approaches. I find the second one a bit more clean.

However, if the user is allowed to provide its own type and its own function,
the second approach doesn't work anymore. Here is what I mean:

namespace my_namespace {
  template <typename T> struct my_type;
  template <typename T> my_type<T> abs(my_type<T>);
}
namespace boost {
  template <typename U> void a_function(U u) {
    do_something(std::abs(u));
  }
}
my_namespace::my_type<int> v;
boost::a_function(v);

This code won't compile because the compiler can't find my_namespace::abs in
boost::a_function. If the first approach (using declaration at namespace scope)
had been used, it would have worked.

Regards,

Guillaume
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to