Boost logo

Boost :

From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2007-05-05 14:44:04


The basic problem is that inside a class template X, Borland cannot
refer to its own specialization as simply X, but must qualify with the
template arguments:

i.e.
template< class T >
struct X {
  typedef X self_type; // most compilers
  typedef X< T > self_type; // Borland requires this
};

Note that there are a couple of places where this IS figured correctly,
and I think that overly-brief example might be one ;¬)

The essential patch follows the same formula, but is applied to each
numbered vector-type in vector50.hpp, vector100.hpp, vector150.hpp and
vector200.hpp.

As a cut-down example:

template< class P0 , class P1 , class P2 >
struct vector3 {
  typedef v_iter<vector3, boost::mpl::int_<0> > begin;

  typedef P0 item0;
  typedef P1 item1;
  typedef P2 item2;
  typedef mpl::int_<1> item3;
  typedef mpl::int_<1> item4;
  typedef mpl::int_<1> item5;
};

becomes:

template< class P0 , class P1 , class P2 >
struct vector3 {

  // Note template args below
  typedef v_iter< vector3< P0, P1, P2 >, boost::mpl::int_<0> > begin;

  typedef P0 item0;
  typedef P1 item1;
  typedef P2 item2;
  typedef mpl::int_<1> item3;
  typedef mpl::int_<1> item4;
  typedef mpl::int_<1> item5;
};

I have marked up all the necessary vectorX in vector50.hpp only (so
far) and all inside a #if BOOST_WORKAROUND for Borland, rather than
mess up the 'clean' registration for other compilers. THis is the
basis of the test results.

Would it be OK to commit this patch? (not attached as it would be a
large and boring file) or would you prefer to look at other kinds of
workaround?

So far I have not investigated the vector.hpp file itself, which I
think is used to generate the 50/100/150/200 files.

The only other relevant change is to update typeof.hpp to use emulated
mode with Borland:

cvs diff -u -wb -- typeof.hpp (in directory
C:\Sourceforge\boost\boost\typeof\)
Index: typeof.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/typeof/typeof.hpp,v
retrieving revision 1.15
diff -u -w -b -r1.15 typeof.hpp
--- typeof.hpp 23 Dec 2006 09:28:50 -0000 1.15
+++ typeof.hpp 8 Feb 2007 16:22:56 -0000
@@ -76,6 +76,15 @@
 # endif
 # endif
 
+#elif defined(__BORLANDC__)
+# ifndef BOOST_TYPEOF_NATIVE
+# ifndef BOOST_TYPEOF_EMULATION
+# define BOOST_TYPEOF_EMULATION
+# endif
+# else
+# error native typeof is not supported
+# endif
+
 #elif defined(_MSC_VER)
 # if (_MSC_VER <= 1300) // 6.5, 7.0
 # ifndef BOOST_TYPEOF_EMULATION

Permission to apply both patches?

-- 
AlisdairM

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