Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2007-09-20 05:52:25


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?

TIA, Markus


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