Boost logo

Boost :

From: John Maddock (john_maddock_at_[hidden])
Date: 2002-04-15 06:58:30


> > Fwiw, here's another possible implementation of is_class on
> Metrowerks:

Interesting.

> Shouldn't your is_class report false for enum_UDT?

Yes enum_UDT should not be reported as a class (it's an enum)

> checking value of boost::is_class<enum_UDT>::value...failed
> found: 1 expected 0
> checking value of boost::is_POD<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of
> boost::has_trivial_constructor<empty_UDT>::value...failed
> found: 0 expected 1
> checking value of
> boost::has_trivial_constructor<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_trivial_copy<empty_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_trivial_copy<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_trivial_assign<empty_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_trivial_assign<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of
> boost::has_trivial_destructor<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of
> boost::has_nothrow_constructor<empty_UDT>::value...failed
> found: 0 expected 1
> checking value of
> boost::has_nothrow_constructor<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_nothrow_copy<empty_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_nothrow_copy<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_nothrow_assign<empty_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::has_nothrow_assign<enum_UDT>::value...failed
> found: 0 expected 1
> checking value of boost::is_empty<int[2]>::value...failed
> boost::is_empty<int[2]>::value does not compile on this compiler
> checking value of boost::is_empty<empty_union_UDT>::value...failed
> boost::is_empty<empty_union_UDT>::value does not compile on this
> compiler
> checking value of boost::is_empty<enum_UDT>::value...failed
> boost::is_empty<enum_UDT>::value does not compile on this compiler
> checking value of
> (boost::is_base_and_derived<Derived,Derived>::value)...failed
> found: 0 expected 1
> checking value of
> (boost::is_base_and_derived<Base,Base>::value)...failed
> found: 0 expected 1
> checking value of
> (boost::is_base_and_derived<Base,Derived>::value)...failed
> found: 0 expected 1
> 201 tests completed, 21 failures found, 19 failures expected from this
> compiler.

I would "expect" all those failures from MWCW: these are either failures
from "we don't know how to implement this without compiler help" - for
example the is_POD, has_trivialXXX and has_nothrowXXX templates, or else
failures from is_convertible, and hence is_enum and hence anything dependent
upon that: has_trivial_assign<empty_UDT>, is_base_and_derived<T>,
is_empty<enum_UDT> etc.

>
> ### mwcc Compiler:
> # In: ..\boost\type_traits\object_traits.hpp
> # From: ..\libs\type_traits\tests\is_function_test.cpp
> # -------------------------------------------------------
> # 400: struct empty_helper_t1 : public T
> # Error: ^
> # illegal struct/union/enum/class definition
> # (instantiating: 'is_function_tester<void (int, bool, int *, int *,
> int, int, int, int, int)>::check()')
> # (instantiating: 'boost::is_empty<void (int, bool, int *, int *,
> int, int, int, int, int)>')
> # (instantiating: 'boost::detail::empty_helper<void (int, bool, int
> *, int *, int, int, int, int, int), 1, 0>')
> # (instantiating: 'boost::detail::empty_helper_t1<void (int, bool,
> int *, int *, int, int, int, int, int)>')
> ### mwcc Compiler:
> # 400: struct empty_helper_t1 : public T
> # Error: ^
> # illegal struct/union/enum/class definition
> # (instantiating: 'is_function_tester<void (int &, bool, int,
> int)>::check()')
> # (instantiating: 'boost::is_empty<void (int &, bool, int, int)>')
> # (instantiating: 'boost::detail::empty_helper<void (int &, bool,
> int, int), 1, 0>')
> # (instantiating: 'boost::detail::empty_helper_t1<void (int &,
> bool, int, int)>')
> ### mwcc Compiler:
> # 400: struct empty_helper_t1 : public T
> # Error: ^
> # illegal struct/union/enum/class definition
> # (instantiating: 'is_function_tester<void (int &,
> double)>::check()')
> # (instantiating: 'boost::is_empty<void (int &, double)>')
> # (instantiating: 'boost::detail::empty_helper<void (int &,
> double), 1, 0>')
> # (instantiating: 'boost::detail::empty_helper_t1<void (int &,
> double)>')
> ### mwcc Compiler:
> # 400: struct empty_helper_t1 : public T
> # Error: ^
> # illegal struct/union/enum/class definition
> # (instantiating: 'is_function_tester<void (int)>::check()')
> # (instantiating: 'boost::is_empty<void (int)>')
> # (instantiating: 'boost::detail::empty_helper<void (int), 1, 0>')
> # (instantiating: 'boost::detail::empty_helper_t1<void (int)>')
> ### mwcc Compiler:
> # 400: struct empty_helper_t1 : public T
> # Error: ^
> # illegal struct/union/enum/class definition
> # (instantiating: 'is_function_tester<void ()>::check()')
> # (instantiating: 'boost::is_empty<void ()>')
> # (instantiating: 'boost::detail::empty_helper<void (), 1, 0>')
> # (instantiating: 'boost::detail::empty_helper_t1<void ()>')

Looks like is_class<function_type>::value is true (wrongly), and hence
is_empty fails to compile for that type - everything else then cascades off
it.

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm


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