empty slices: defined?

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Nov 7 18:50:00 GMT 2005


DJ Delorie <dj@redhat.com> writes:

| A few related questions:
| 
| If one explicitly constructs a slice or glice with the default
| constructor, does the standard require this slice to have any usable
| state?  It says "creates a slice which specifies no elements", which
| could be interpreted two ways:
| 
| 1. There are no elements to which the slice refers (i.e. undefined).
| 2. The slice specifies an array with no elements in it (i.e. defined).
| 
| While slice's default constructor's standard explicitly limits its use
| to declaring arrays of slices, the gslice standard does not limit its
| use.  How is the standard to be interpreted?  There is no obvious
| "don't do that" nor is there an obvious "you can do that".

I guess the question I have is what would you do with an empty slice?  
What useful purpose does it serve?
In general, valarray is specificed in such a way that its
implementation shall not check for "boundary" conditions.

-- Gaby



More information about the Libstdc++ mailing list