
2016-03-03 23:18 GMT+01:00 Daniel Frey <d.frey@gmx.de>:
On 03.03.2016, at 22:57, Andrzej Krzemienski <akrzemi1@gmail.com> wrote:
The Standard ([meta.rel]) requires that in std::is_base_of<B, D> D must be a complete type, but it does not require the same of B. This makes sense, because if we compare a complete type D and an incomplete type B, the former is surely not derived from the latter. In contrast, boost::is_base_of imposes an additional constraint that B must also be complete. Could this restriction be lifted?
That would probably be possible for all modern compilers that have a proper std::is_base_of because it requires a compiler intrinsic (unless you can implement it without such an intrinsic and in C++98). Boost.TypeTraits have quite a history and by lifting the restriction, you would drop support for old compilers (think pre-C++11).
And if you really need this feature, why not use std::is_base_of directly? Either your compiler has it or it can’t be implemented AFAICT.
I need it for patching boost::optional. It must work on any system. I do not know how to portably check if a given compiler defines std::is_base_of. What I do not understand now is why the following small program compiles: http://melpon.org/wandbox/permlink/2RCFt448BwwKcwob I also paste it here ``` #include <boost/core/enable_if.hpp> #include <boost/type_traits/is_base_of.hpp> #include <iostream> struct factory_base; typedef char true_type; typedef struct {char _[2];} false_type; template <typename T> typename boost::enable_if_c<!boost::is_base_of<factory_base, T>::value, true_type>::type fun(T&&) { puts("val"); return true_type(); } template <typename T> typename boost::enable_if_c<boost::is_base_of<factory_base, T>::value, false_type>::type fun(T&&) { puts("factory"); return false_type(); } int main() { fun(1); } ``` It can handle boost::is_base_of with an incomplete type. SFINAE should only work on "surface" compilation errors. But boost::is_base_of has an explicit static assertion INSIDE the body. Regards, &rzej