Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-01-15 20:50:36


Below is a simple example that I cannot get to compile. I would like to
create a subclass of boost::array in order to give it some additional
functionality (I would like a associative array like interface).

When I compile this, I get an "illegal initialization" error for test.

I am using Metrowerks Codewarrior 7 on Mac OS X.

Is there some special incantation required? I suspect that I am in some
kind of specialized area and I cant get there from here.

template < class T, std::size_t N >
struct test_array : public boost::array< T, N >
{
};

static boost::array< char,1 > array_test = {{ 'a' }};
static test_array< char, 1 > test = {{ 'a' }};

It appears that if I aggregate instead of inherit that this might work
(at least it compiles :-)

template < class T, std::size_t N >
struct test_array
{
    boost::array< T, N > array_;
};

static boost::array< char,1 > array_test = {{ 'a' }};
static test_array< char, 1 > test = {{ 'a' }};
// The funny thing is this works also:
static test_array< char, 1 > test2 = { 'a' };

TIA,
 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net