is_base_of: bug in trunk, not in sandbox

Thanks to Christopher Jefferson, I discovered a bug in the trunk (in fact in 1.46.0) for is_base_of in the type_traits library. is_base_of<int, int>::value should be true according to the doc: "is_base_of<Base, Base>::value is an integral constant expression that evaluates to true: a class is regarded as it's own base. However the following program prints 0 and not 1 with g++ 4.4.5 on linux: #include <boost/type_traits/is_base_of.hpp> #include <iostream> int main() { std::cout<<::boost::is_base_of<int, int>::value<<'\n'; return 0; } Using the sandbox version of is_base_of works just fine. This makes my type trait extension fail on 6 tests when using only the trunk (for the 6 comparison operators). I have a workaround for my extension which is to add "or is_same<T, U>" but it would be better if is_base_of would work correctly. Frédéric

AMDG On 03/10/2011 04:54 AM, Frédéric Bron wrote:
Thanks to Christopher Jefferson, I discovered a bug in the trunk (in fact in 1.46.0) for is_base_of in the type_traits library.
is_base_of<int, int>::value should be true according to the doc: "is_base_of<Base, Base>::value is an integral constant expression that evaluates to true: a class is regarded as it's own base.
int is not a class. In Christ, Steven Watanabe

You are right. int is just a type! Then the sanbox is wrong. It would be nice to remove from the sandbox what is obsolete.
Feel free to do so - that sandbox copy was created explicitly for you as I recall?
I am not sure it was created for me but: 1. I have removed is_base_of.hpp and is_base_and_derived.hpp from the sandbox, 2. I have fixed the bug in my addition to account for the new behaviour of is_base_of. All tests pass (this time with only my additions above 1.46.0) for: - g++ 4.4.5 on Linux, - intel 10.0 and 11.1 on Linux. sandbox and vault updated. Chris, could you try again? Edward, would you be so kind to run the msvc tests once again... Kind regards, Frédéric

On 3/10/2011 4:53 PM, Frédéric Bron wrote:
You are right. int is just a type! Then the sanbox is wrong. It would be nice to remove from the sandbox what is obsolete.
Feel free to do so - that sandbox copy was created explicitly for you as I recall?
I am not sure it was created for me but: 1. I have removed is_base_of.hpp and is_base_and_derived.hpp from the sandbox, 2. I have fixed the bug in my addition to account for the new behaviour of is_base_of.
All tests pass (this time with only my additions above 1.46.0) for: - g++ 4.4.5 on Linux, - intel 10.0 and 11.1 on Linux.
sandbox and vault updated. Chris, could you try again? Edward, would you be so kind to run the msvc tests once again...
Test pass with no errors for VC++ 8,9, and 10.

2011/3/10 Steven Watanabe <watanabesj@gmail.com>
Thanks to Christopher Jefferson, I discovered a bug in the trunk (in
fact in 1.46.0) for is_base_of in the type_traits library.
is_base_of<int, int>::value should be true according to the doc: "is_base_of<Base, Base>::value is an integral constant expression that evaluates to true: a class is regarded as it's own base.
On 03/10/2011 04:54 AM, Frédéric Bron wrote: int is not a class.
Hello, I am about to use is_base_of, and remembered this discussion, so I looked into the docs. From 1.45.0 docs: Note that is_base_of<X,X> will always inherit from true_type. This is the case even if X is not a class type. This is a change in behaviour from Boost-1.33 in order to track the Technical Report on C++ Library Extensions. I understand, that this means is_base_of<int,int> should be true. Has this changed in 1.46.0, or are the docs wrong? Regards, Kris.

Thanks to Christopher Jefferson, I discovered a bug in the trunk (in
fact in 1.46.0) for is_base_of in the type_traits library.
is_base_of<int, int>::value should be true according to the doc: "is_base_of<Base, Base>::value is an integral constant expression that evaluates to true: a class is regarded as it's own base.
On 03/10/2011 04:54 AM, Frédéric Bron wrote: int is not a class.
Has this changed in 1.46.0, or are the docs wrong?
It changed prior to 1.46 (not sure which version off hand), so yes the docs are out of date. John.

Thanks to Christopher Jefferson, I discovered a bug in the trunk (in fact in 1.46.0) for is_base_of in the type_traits library.
is_base_of<int, int>::value should be true according to the doc: "is_base_of<Base, Base>::value is an integral constant expression that evaluates to true: a class is regarded as it's own base.
I will make the docs clearer on this point, but there was a change between TR1 and C++0x behavior which means that is_base_of<T, T>::value is true only for class types, and in recent releases is_base_of has changed to follow C++0x behavior. HTH, John.
participants (5)
-
Edward Diener
-
Frédéric Bron
-
John Maddock
-
Krzysztof Czainski
-
Steven Watanabe