Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-11-05 11:31:55


--- In boost_at_y..., Bill Seymour <bill-at-the-office_at_p...> wrote:
> I've discovered one reason why I'm having trouble
> compiling the fixed-point decimal library with
> MSVC v5. In a nutshell:
>
> template<typename T> struct foo { };
>
> template<typename U>

Why is this templatized? Is it important for the bug you're trying
to work around?

> struct bar
> {
> bar(const foo<int>&);
> bar(const foo<double>&);
> };
>
> On the line with the second ctor, the compiler tells me
> that bar(const foo&) is already declared (so it's not
> recognizing foo<int> and foo<double> as distinct types).
> If I make bar a non-template class by just commenting
> out the template<typename U> line, it works OK.
>
> Is this a problem with MSVC v6, too? If so, is there
> a workaround?

Using MSVC 6 SP5 the following compiles with out a hitch.

template<typename T> struct foo { };

struct bar
{
    bar(const foo<int>&) { }
    bar(const foo<double>&) { }
};

int main()
{
    foo<double> fd;
    bar b(fd);
    return 0;
}

Bill Kempf


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