[compressed pair] Borland patch

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[compressed pair] Borland patch

AlisdairM
Borland does not like the new version of compressed pair.

It turns out it cannot handle static_cast-ing a class to reference to
private base, although it will allow implicit conversion.  Hence the
patch simply drops the casts on the Borland compilers:

cvs diff -wb -- boost\detail\compressed_pair.hpp (in directory
E:\sourceforge\devel\boost\)
Index: boost/detail/compressed_pair.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/detail/compressed_pair.hpp,v
retrieving revision 1.13
diff -w -b -r1.13 compressed_pair.hpp
157a158,161
> #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
>       first_reference       first()       {return *this;}
>       first_const_reference first() const {return *this;}
> #else
159a164
> #endif
202a208,211
> #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
>       second_reference       second()       {return *this; }
>       second_const_reference second() const {return *this; }
> #else
204a214
> #endif
243a254,260
> #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
>       first_reference       first()       {return *this;}
>       first_const_reference first() const {return *this;}
>
>       second_reference       second()       {return *this; }
>       second_const_reference second() const {return *this; }
> #else
248a266
> #endif
282a301,304
> #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
>       first_reference       first()       {return *this;}
>       first_const_reference first() const {return *this;}
> #else
284a307
> #endif

--
AlisdairM

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [compressed pair] Borland patch

Robert Kawulak
> From: AlisdairM

> Borland does not like the new version of compressed pair.

That's a pity... OTOH with Borland 5.6.4 it compiles fine.

> 157a158,161
> > #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581))
> >       first_reference       first()       {return *this;}
> >       first_const_reference first() const {return *this;}
> > #else
> 159a164
> > #endif

I think this should rather be:

#if BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x846))
#define BOOST_PRIVATE_BASE_CAST(type, arg) static_cast<type>(arg)
#else
#define BOOST_PRIVATE_BASE_CAST(type, arg) (arg)
#endif

And later in the appropriate lines:

first_reference first()
  { return BOOST_PRIVATE_BASE_CAST(first_reference, *this); }
first_const_reference first() const
  { return BOOST_PRIVATE_BASE_CAST(first_const_reference, *this);
}

Best regards,
Robert


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [compressed pair] Borland patch

Robert Kawulak
In reply to this post by AlisdairM
> From: Robert Kawulak

> I think this should rather be:
>
> #if BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x846))
> #define BOOST_PRIVATE_BASE_CAST(type, arg)
static_cast<type>(arg)

> #else
> #define BOOST_PRIVATE_BASE_CAST(type, arg) (arg)
> #endif
>
> And later in the appropriate lines:
>
> first_reference first()
>   { return BOOST_PRIVATE_BASE_CAST(first_reference, *this); }
> first_const_reference first() const
>   { return BOOST_PRIVATE_BASE_CAST(first_const_reference,
*this); }

I think I just found a better solution - if the base classes of
compressed_pair_imp are protected instead of private, then DMC
compiles this fine (and four other compilers I've tested too),
and the code isn't cluttered with macros.

Best regards,
Robert


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [compressed pair] Borland patch

AlisdairM
In reply to this post by Robert Kawulak
Robert Kawulak wrote:

> That's a pity... OTOH with Borland 5.6.4 it compiles fine.

The problem showed up in metacomm regressions last night, so I believe
the problem is present in 5.6.4 too.

There also seems to be some link to whether the 'zero size base class'
compiler option is enabled, which seems a strange to produce a
front-end rather than back-end error.

The proposed patch should solve problem regardless of compiler version,
or selected options.

If the same patch is needed for DMC I agree naming it once, rather than
compiler-detecting each time, makes sense.  Personally I find the
WORKAROUND clearer than having a function-like macro expand to the
right thing, but that is the library maintainers choice ;?)

--
AlisdairM

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [compressed pair] Borland patch

David Abrahams
In reply to this post by AlisdairM
"AlisdairM" <[hidden email]> writes:

> Borland does not like the new version of compressed pair.
>
> It turns out it cannot handle static_cast-ing a class to reference to
> private base, although it will allow implicit conversion.  Hence the
> patch simply drops the casts on the Borland compilers:
>
> cvs diff -wb -- boost\detail\compressed_pair.hpp (in directory
> E:\sourceforge\devel\boost\)

Alisdair, it's a bit nicer if you can use diff -dbu, or -du.  Unified
diffs are easier to understand, and while -b sometimes loses
indentation, -w can miss crucial changes.  In any case there's not
much point in using -w and -b together, is there?

nanny-ly y'rs,
Dave

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [compressed pair] Borland patch

John Maddock
In reply to this post by Robert Kawulak
> I think I just found a better solution - if the base classes of
> compressed_pair_imp are protected instead of private, then DMC
> compiles this fine (and four other compilers I've tested too),
> and the code isn't cluttered with macros.

Just to be clear about this:  if I change the base classes to protected, and
remove the explicit casts, then it works OK with DMC?  If so that gets us
almost back to the original code, and should work everywhere.

John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [compressed pair] Borland patch

Robert Kawulak
Hi,

> From: John Maddock

> Just to be clear about this:  if I change the base classes to
> protected, and
> remove the explicit casts, then it works OK with DMC?

That's right, at least my tests with the latest DMC version
confirm this.

>  If so that gets us
> almost back to the original code, and should work everywhere.

I hope so ;-)

Best regards,
Robert


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