Boost logo

Boost :

Subject: Re: [boost] attempting sandbox svg_plot templates
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2012-08-25 05:50:00


> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Jan Hudec
> Sent: Friday, August 24, 2012 7:04 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] attempting sandbox svg_plot templates
>
> On Tue, Aug 21, 2012 at 15:09:02 -0400, Roger Martin wrote:
> > Run into many template and friend issues. Anybody getting this lib to work?
> >
> > Much coming from
> https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization/boost/svg_plot/uncertain.hpp.
> > First two:
> > ..............
> > In file included from
> > ../../testing-grounds/divcon-support_libs/local/r.linux-x86_64.gcc-sha
> > red/include/boost/svg_plot/svg_2d_plot.hpp:32:0,
> > from tests/plotting_tests.cpp:21:
> > ../../testing-grounds/divcon-support_libs/local/r.linux-x86_64.gcc-
> shared/include/boost/svg_plot/uncertain.hpp:241:11:
> > required from here
> > ../../testing-grounds/divcon-support_libs/local/r.linux-x86_64.gcc-
> shared/include/boost/svg_plot/uncertain.hpp:97:24:
> > error: template-id ‘operator<< <>’ for ‘std::ostream&
> > boost::svg::operator<<(std::ostream&, const boost::svg::unc<false>&)’
> > does not match any template declaration
> > ../../testing-grounds/divcon-support_libs/local/r.linux-x86_64.gcc-
> shared/include/boost/svg_plot/uncertain.hpp:102:24:
> > error: template-id ‘operator<< <>’ for ‘std::ostream&
> > boost::svg::operator<<(std::ostream&, const
> > std::pair<boost::svg::unc<false>, boost::svg::unc<false> >&)’ does not
> > match any template declaration ..............
>
> It's making friends with templates that don't exist. I don't think the involved templates can work in any
> compler, ever.
>
> There is however big difference between Gcc and Visual C++ in treating of templates. Gcc parses
> everything as it comes across it and insists that it's well-formed, while VC++ delays lot of it until
> instantiation, apparently in an attempt to relieve programmers from having to write `typename` and
> `template` in many cases. That means Gcc will complain about things like this while VC++ won't.
>
> However the templates seem pretty bogus. There is a
>
> template <bool correlated> class unc;
>
> followed up by
>
> template<typename correlated> std::ostream& operator<< (std::ostream& os, const unc<false>& u);
>
> followed up by
>
> friend std::ostream& operator<< <> (std::ostream& os, const unc<correlated>& u);
>
> and that simply does not add up under any compiler. The middle template is not using it's template
> argument in it's signature, so it's neither possible to give it's specialization as the friend declaration is
> trying to do, nor is it actually useful, because you'd need to give the template parameter explicitly, so the
> only possible call syntax is
>
> operator<< <whatever> (out, u)
>
> and that certainly does not look like what was intended.
>
> So I suggest you just try to comment the offending declarations out and see if it gets you somewhere.

I'm sure you are right - but MSVC seems to swallow it and it works.

Friends sometime seem more trouble than they are worth ;-)

But I'm getting round to being able to work with both compilers, aided by the original 'complainant' Roger Martin.

Watch this space...

Paul


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