|
Boost : |
Subject: Re: [boost] [type_traits] revisiting is_virtual_base_of
From: John Maddock (jz.maddock_at_[hidden])
Date: 2018-05-10 07:54:40
On 02/02/2018 20:16, Steven Watanabe via Boost wrote:
> AMDG
>
> On 02/02/2018 12:13 PM, John Maddock via Boost wrote:
>> There is a problem with is_virtual_base_of in that it doesn't work
>> especially well - most of the time it works OK, but can be made to fail
>> catastrophically in a few situations, see for example:
>> https://svn.boost.org/trac10/ticket/11323
>>
>> Now... it turns out that with C++14 and later we now have is_detected
>> which can test the validity of almost any expression... and I'm
>> wondering if there's a cunning way to press this into action to create a
>> more accurate is_virtual_base_of, but I'm having trouble coming up with
>> anything. Any bright ideas? Note that an explicit static_cast can't be
>> tested for, though we can use is_constructible if required.
>>
> Testing for static_cast<Derived*>(Base*) mostly
> works, except for private (or protected) virtual inheritance.
Thanks Steven, it turns out there was a PR I'd been sitting on that used
just this technique - works an absolute treat for gcc and msvc including
for private and protected inheritance, but fails to build in every case
for clang :(
See https://github.com/boostorg/type_traits/pull/71
Hopefully someone will spot a workaround for clang....
Thanks, John.
--- This email has been checked for viruses by AVG. http://www.avg.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk