[type_traits] common_type fails when typeof is not used

Hi, The current common_type implementation doesn't works when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is defined. This is needed on platforms that don't support Boost.Typeof correctly. It seems that the the implementation proposed by Jeffrey Hellrung has not been applied completly. I have attached a complementaty test on builting types that proves the current code does't works and also the implementation proposed by Jeffrey Hellrung to solve these issues some time ago. John, let me know if this works for you and if it can be included on trunk (I could do it myself if you prefer). Best, _____________________ Vicente Juan Botet Escribá http://viboes.blogspot.com/

On 1/11/2011 1:31 PM, vicente.botet wrote:
Hi,
The current common_type implementation doesn't works when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is defined. This is needed on platforms that don't support Boost.Typeof correctly.
It seems that the the implementation proposed by Jeffrey Hellrung has not been applied completly. I have attached a complementaty test on builting types that proves the current code does't works and also the implementation proposed by Jeffrey Hellrung to solve these issues some time ago.
John, let me know if this works for you and if it can be included on trunk (I could do it myself if you prefer).
Let me know of any hiccups that I can help with. - Jeff

The current common_type implementation doesn't works when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is defined. This is needed on platforms that don't support Boost.Typeof correctly.
It seems that the the implementation proposed by Jeffrey Hellrung has not been applied completly. I have attached a complementaty test on builting types that proves the current code does't works and also the implementation proposed by Jeffrey Hellrung to solve these issues some time ago.
John, let me know if this works for you and if it can be included on trunk (I could do it myself if you prefer).
Fixed header applied to Trunk as of rev 68040. I modified your tests somewhat and added updated test cases as well (with one case to test when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is defined). Thanks! John.

----- Original Message ----- From: "John Maddock" <boost.regex@virgin.net> To: <boost@lists.boost.org> Sent: Wednesday, January 12, 2011 2:32 PM Subject: Re: [boost] [type_traits] common_type fails when typeof is not used
Fixed header applied to Trunk as of rev 68040.
I modified your tests somewhat and added updated test cases as well (with one case to test when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is defined).
Thanks! John.
Thanks John. There is yet an error on Sun compiler that is not really related to common_type code, but to the test code itself. Test output: Sandia-sun - type_traits - common_type_test / sun-5.10 Rev 68075 / Thu, 13 Jan 2011 01:15:43 +0000 Report Time: Thu, 13 Jan 2011 04:05:07 +0000 Compile [2011-01-13 02:07:06 UTC]: fail "/opt/sunstudio12.1/bin/CC" +d -library=stlport4 -features=tmplife -features=tmplrefstatic -g -erroff=%none -errwarn -m64 -KPIC -DBOOST_ALL_NO_LIB=1 -I".." -c -o "/scratch2/kbelco/boost/results/boost/bin.v2/libs/type_traits/test/common_type_test.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/common_type_test.o" "../libs/type_traits/test/common_type_test.cpp" "../libs/type_traits/test/common_type_test.cpp", line 47: Error: ac must be initialized. "../libs/type_traits/test/common_type_test.cpp", line 88: Where: While instantiating "assignation_2<C1C2, C1>()". "../libs/type_traits/test/common_type_test.cpp", line 88: Where: Instantiated from non-template code. On the web I have found that Warning: Objects of type AAAA must be initialized This warning is produced when you use new() to allocate a const object without providing an initial value or a default constructor, as shown in the following example: const int * ip = new const int; This is an error, since constants of unknown value are not useful. The solution is to add an initializer. The preceding example would then become const int * ip = new const int(0); I guess that we can change the test code so the default constructor is explicit to avoid this Sun error struct C1 { C1() {}; }; struct C2 { C1() {};}; Best, Vicente

I modified your tests somewhat and added updated test cases as well (with one case to test when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is defined).
Thanks! John.
Thanks John.
There is yet an error on Sun compiler that is not really related to common_type code, but to the test code itself.
It's a bug in common_type.hpp (or the compiler), since common_type<C1C2, C1>::type evaluates to C1C2& and not C1C2. The same code compiled with msvc does the right thing though... Any ideas? John.
participants (3)
-
Jeffrey Lee Hellrung, Jr.
-
John Maddock
-
vicente.botet