Re: ustring problem



On Thursday 01 September 2005 23:31, Erwin Rol wrote:
> On Thu, 2005-09-01 at 22:57 +0100, Chris Vine wrote:
> > On Thursday 01 September 2005 21:45, Erwin Rol wrote:
> >
> > gcc-4.0 does allow static member variables to be initialised inline.  So
> > do gcc-3.2, 3.3 and 3.4, with x86 at any rate.
> >
> > Older pre-C++98 compilers may not.  What does 'gcc --version' tell you? 
> > You may have more than one compiler installed and be calling the wrong
> > one.
>
> gcc (GCC) 4.0.1 20050831 (Red Hat 4.0.1-12)
> and the system is;
> Linux xpc.home.erwinrol.com 2.6.12-1.1519_FC5 #1 SMP Sat Aug 27 13:54:40
> EDT 2005 x86_64 x86_64 x86_64 GNU/Linux
>
> Its not the wrong compiler, i am sure about that.
>
> And the problem is not that the member variables are initialized inline,
> the problem is that std::string::npos is not constant, and so can not be
> used to initialize static inline initialization.

gcc-4.0.1 defines npos, as follows:

  static const size_type pos = static_cast<size_type>(-1);

See the members of:

  template<typename _CharT, typename _Traits, typename _Alloc>
    class basic_string;

in the file bits/basic_string.h.

Perhaps your redhat version does something different, but in the standard gcc 
distribution it is definitely a constant.

Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]