|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2007-09-20 17:10:32
Markus Schöpflin wrote:
> Hello,
>
> this file contains code to create an error condition, which basically looks
> like this:
>
> ---%<---
> struct foo
> {
> foo() {}
> template <class T> foo(T t) { *this = make_foo(t); }
> };
>
> inline foo make_foo(int i) { return foo(); }
>
> foo f(42);
> --->%---
>
> Both my compiler (Tru64 CXX 7.1) and Comeau C++ Online think this code is
> in error:
>
> ---%<---
> cxx: Error: test.cxx, line 4: identifier "make_foo" is undefined
> detected during instantiation of "foo::foo(T) [with T=int]" at
> line 9
> template <class T> foo(T t) { *this = make_foo(t); }
> ----------------------------------------^
> --->%---
>
> Therefore I think this should be changed to the following:
>
> ---%<---
> struct foo;
> template <class T> foo make_foo(T);
>
> struct foo
> {
> foo() {}
> template <class T> foo(T t) { *this = make_foo(t); }
> };
>
> template<> foo make_foo(int i) { return foo(); }
>
> foo f(42);
> --->%---
>
> Is this correct? If yes, could that header be fixed?
AFAICT you are correct. I've updated the header accordingly.
I deliberately did not change error_code_user_test.cpp. It may require
"template<>" be inserted in front of make_error_* overloads, but I want
to let the test run through Tru64 CXX 7.1 to verify that before I change
the test code. AFAIK, the code will still work OK with the compilers it
is currently working with.
Thanks for the report and fix!
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk