Boost logo

Boost :

From: George A. Heintzelman (georgeh_at_[hidden])
Date: 2001-07-19 10:16:04


Hi boosters,

I have two small fixes in array_traits.hpp, which I have found very
useful (aside -- what's the status on moving this from beta into more
formal acceptance?).

First, using boost::size generates a warning on my compiler
(g++-2.95.2) with an usused parameter. Second, boost::sizer does not
work for arrays of const. Since reading comments below suggests that
g++-2.95 has trouble with the const-ness of arrays, I suspect that this
is also a compiler-specific problem. So, I've put it inside an #ifdef
as with the later code.

Unfortunately, the only other compiler I have easy access to, Solaris
CC version 6.1 fails miserably attempting to compile the definition of
sizer. Because of this I couldn't verify that it would have
successfully dealt with the constness issue. Probably solaris CC needs
to have sizer #ifdef'd out completely so that solaris CC users can at
least have some of the functionality.

Anyway, here are my diffs which help for g++-2.95. Presumably the
#ifdef __GNUG__ here and later in the file needs to be changed to do
something with boost/config, but I'll leave that for another time.

George Heintzelman
georgeh_at_[hidden]

Index: array_traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/array_traits.hpp,v
retrieving revision 1.3
diff -c -r1.3 array_traits.hpp
*** array_traits.hpp 2001/02/02 20:58:53 1.3
--- array_traits.hpp 2001/07/19 15:03:56
***************
*** 93,104 ****
        typedef value_type* pointer;
        static iterator begin(T const (&array)[sz]) { return array; }
        static iterator end(T const (&array)[sz]) { return array + sz; }
! static size_type size(T const (&array)[sz]) { return sz; }
      };
  
    template <typename T, int sz>
    inline char (&sizer(T (&)[sz]))[sz];
!
    // --- general version of the global accessor functions
---------------------
  
    template <typename Cont>
--- 93,108 ----
        typedef value_type* pointer;
        static iterator begin(T const (&array)[sz]) { return array; }
        static iterator end(T const (&array)[sz]) { return array + sz; }
! static size_type size(T const (&)[sz]) { return sz; }
      };
  
    template <typename T, int sz>
    inline char (&sizer(T (&)[sz]))[sz];
! #ifdef __GNUG__
! template <typename T, int sz>
! inline char (&sizer(T const (&)[sz]))[sz];
! #endif
!
    // --- general version of the global accessor functions
---------------------
  
    template <typename Cont>


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