Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2005-04-11 07:57:55


Arkadiy Vertleyb wrote:
> Hi everybody,
>
> If anybody can try or has recently tried the proposed typeof library with
> any compilelr, other than GCC or MSVC, can you please let me know what the
> results are?
>
> You can take the library at its usual place:
>
> http://boost-sandbox.sourceforge.net/vault/, typeof.zip

Hi Arkadiy,

here are my results from testing with different versions of BCC.

I had to tweak things around a bit to see some more than just the first
lethal problem and attached a patch to document the changes described in
this post. Note that this is _not_ intended as a patch to the library
since things can and should be fixed more properly.

BCC dies parsing the source:

  Error E2040 e:\Libs\Boost\MainCVS\boost/typeof/compliant/vector.hpp 56:
  Declaration terminated incorrectly

  Error E2299 e:\Libs\Boost\MainCVS\boost/typeof/compliant/vector.hpp 56:
  Cannot generate template specialization from 'v_iter<V,Pos>'

This is macro code so the error actually comes from line 49.
I changed the macro definition to:

  typedef vector ## n self;
  typedef v_iter<self , boost::mpl::int_<0> > begin;

After fixing this it continues to complain in other places:

All function-releated types other than function pointers cannot be
handled by template specialization.
This can be worked around for plain functions and function references by
detecting them as function pointers (I still have some toy code for
this, somewhere - in case you are interested). Member function pointers
can only be matched via overloading when compiling with BCC.

I just disabled the lower part of 'register_functions_iterate.hpp', for now.

After this I get error from within the test suite (using the latest
version):

Borland C++ 5.6.5 for Win32 Copyright (c) 1993, 2004 Borland
main.cpp:
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_CHECK_2'
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_ELEM_III'
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_TYPEOF_MAKE_OBJ'
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_CHECK_2'
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_ELEM_III'
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_HEAD'
Error E2303 mpl/register.hpp 14: Type name expected
Error E2293 mpl/register.hpp 14: ) expected
Error E2293 mpl/register.hpp 14: ) expected
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_ELEM_III'
Error E2219 mpl/register.hpp 14: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_HEAD'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_CHECK_2'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_ELEM_III'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_TYPEOF_MAKE_OBJ'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_CHECK_2'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_ELEM_III'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_HEAD'
Error E2303 mpl/register.hpp 15: Type name expected
Error E2238 mpl/register.hpp 15: Multiple declaration for
'BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_DEC_BOOST_PP_SEQ_SIZE_BOOST_PP_SEQ_SIZE_0BOOST_PP_SEQ_TAIL_IBOOST_PP_TUPLE_ELEM_3_2BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_DEC_BOOST_PP_SEQ_SIZE_BOOST_PP_SEQ_SIZE_0BOOST_PP_IIF_'
Error E2344 mpl/register.hpp 14: Earlier declaration of
'BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_DEC_BOOST_PP_SEQ_SIZE_BOOST_PP_SEQ_SIZE_0BOOST_PP_SEQ_TAIL_IBOOST_PP_TUPLE_ELEM_3_2BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_DEC_BOOST_PP_SEQ_SIZE_BOOST_PP_SEQ_SIZE_0BOOST_PP_IIF_'
Error E2293 mpl/register.hpp 15: ) expected
Error E2293 mpl/register.hpp 15: ) expected
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_ELEM_III'
Error E2219 mpl/register.hpp 15: Wrong number of arguments in call of
macro 'BOOST_PP_SEQ_HEAD'
Error E2219 mpl/register.hpp 16: Wrong number of arguments in call of
macro 'BOOST_PP_CHECK_2'
Error E2228 mpl/register.hpp 16: Too many error or warning messages
*** 26 errors in Compile ***

Looks like something goes wrong preprocessing (I stopped here).

There's even more trouble with Version 5.5:

It complains about "size_t" in template paramter lists in
'typeof_impl.hpp'. I believe the type is just not visible at this point
because using "std::size_t" instead solves it.

The identifiers "at" and "size" seem to clash (with mpl ? - I did not
fix this).

And while we're at it - this (found in 'typeof_impl.hpp') can be
problematic, too:

   template<...> char (&func(params))[ ice ];

and can be worked around like this:

   typename char_array< ice >::type func(params);

The "size_t-issue" mentioned above continues in 'int_encoding.hpp' and
"pack<...>::value" needs full qualification when used as a non-type
template argument, so the compiler correctly it as an integral constant
expression.

Then BCC <= 5.5 finally dies with an internal compiler error (I didn't
try to fix things any further because I wasn't sure that "compliant" is
the right implementation type for BCC and if you plan to support old BCC
versions, anyway | this might have to do with the unfixed name clash,
metioned above).

Regards,

Tobias

diff -ruN typeof/compliant/int_encoding.hpp typeof_modified/compliant/int_encoding.hpp
--- typeof/compliant/int_encoding.hpp Fri Mar 4 21:36:00 2005
+++ typeof_modified/compliant/int_encoding.hpp Mon Apr 11 12:24:17 2005
@@ -37,13 +37,13 @@
 
     //////////////////////////
 
- template<size_t n, bool Overflow>
+ template<std::size_t n, bool Overflow>
     struct pack
     {
         enum {value = (n + 1) * 2 + (Overflow ? 1 : 0)};
     };
 
- template<size_t m>
+ template<std::size_t m>
     struct unpack
     {
         enum {value = (m / 2) - 1};
@@ -52,17 +52,17 @@
 
     ////////////////////////////////
 
- template<class V, size_t n, bool overflow = (n >= 0x3fffffff)>
+ template<class V, std::size_t n, bool overflow = (n >= 0x3fffffff)>
     struct encode_size_t : mpl::push_back<
         V,
- boost::mpl::size_t<pack<n, false>::value>
+ boost::mpl::size_t< ::boost::type_of::pack<n, false>::value>
>
     {};
 
- template<class V, size_t n>
+ template<class V, std::size_t n>
     struct encode_size_t<V, n, true> : mpl::push_back<typename mpl::push_back<
         V,
- boost::mpl::size_t<pack<n % 0x3ffffffe, true>::value> >::type,
+ boost::mpl::size_t< ::boost::type_of::pack<n % 0x3ffffffe, true>::value> >::type,
         boost::mpl::size_t<n / 0x3ffffffe>
>
     {};
@@ -73,17 +73,17 @@
 
     ///////////////////////////
 
- template<size_t n, class Iter, bool overflow>
+ template<std::size_t n, class Iter, bool overflow>
     struct decode_size_t;
 
- template<size_t n, class Iter>
+ template<std::size_t n, class Iter>
     struct decode_size_t<n, Iter, false>
     {
         enum {value = n};
         typedef Iter iter;
     };
 
- template<size_t n, class Iter>
+ template<std::size_t n, class Iter>
     struct decode_size_t<n, Iter, true>
     {
         enum {m = boost::mpl::deref<Iter>::type::value};
diff -ruN typeof/compliant/register_functions_iterate.hpp typeof_modified/compliant/register_functions_iterate.hpp
--- typeof/compliant/register_functions_iterate.hpp Sun Mar 20 18:38:00 2005
+++ typeof_modified/compliant/register_functions_iterate.hpp Mon Apr 11 12:00:46 2005
@@ -28,8 +28,9 @@
 
     // function references
 
+#if !defined(__BORLANDC__) || __BORLANDC__ > 0x0645
     template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
- struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P))>
+ struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P)) >
     {
         typedef R BOOST_PP_CAT(P, n);
         typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_REF_ID + n) type;
@@ -79,6 +80,7 @@
     #define BOOST_TYPEOF_qualifier volatile const
     #define BOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID
     #include <boost/typeof/compliant/register_mem_functions.hpp>
+#endif
 }
 
 #undef n
diff -ruN typeof/compliant/typeof_impl.hpp typeof_modified/compliant/typeof_impl.hpp
--- typeof/compliant/typeof_impl.hpp Fri Mar 4 21:36:00 2005
+++ typeof_modified/compliant/typeof_impl.hpp Mon Apr 11 12:38:42 2005
@@ -24,15 +24,29 @@
 
 namespace boost{namespace type_of{
 
+ template<std::size_t N>
+ struct char_array
+ {
+ typedef char (&type)[ N ];
+ };
+
+ template<typename T>
+ struct value_of
+ {
+ BOOST_STATIC_CONSTANT(std::size_t, value = T::value);
+ };
+
     template<int pos, class T>
- char(&at(const T&))[
- mpl::at<typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T>::type, mpl::int_<pos> >::type::value
- ];
+ typename char_array<
+ ::boost::type_of::value_of< typename mpl::at<typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T>::type, mpl::int_<pos> >::type >::value
+ >::type
+ at(const T&);
 
     template<class T>
- char(&size(const T&))[
- mpl::size<typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T>::type>::value
- ];
+ char_array<
+ ::boost::mpl::size<typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T>::type>::value
+ >::type
+ size(const T&);
 }}
 
 #define BOOST_TYPEOF_AT(n, expr) sizeof(boost::type_of::at<n>(expr))
diff -ruN typeof/compliant/vector.hpp typeof_modified/compliant/vector.hpp
--- typeof/compliant/vector.hpp Sat Mar 19 15:18:00 2005
+++ typeof_modified/compliant/vector.hpp Mon Apr 11 11:40:09 2005
@@ -45,8 +45,9 @@
     template<BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_COMMA_IF(n) class T = void>\
     struct vector ## n\
     {\
+ typedef vector ## n self;\
         typedef v_tag tag;\
- typedef v_iter<vector ## n, boost::mpl::int_<0> > begin;\
+ typedef v_iter<self , boost::mpl::int_<0> > begin;\
         typedef mpl::int_<n> size;\
         BOOST_PP_REPEAT(n, BOOST_TYPEOF_typedef_item, ~)\
     };


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