If I remember right, the use of inheritance means that your test_array is not an "aggregate" type according to the C++ std, and can not be initialize with {}'s. Why don't you create your associative array-like interface via free-functions in terms of boost::array itself? Member functions are lame anyways ;) Cheers, Jeremy On Tue, 15 Jan 2002, Duane Murphy wrote:
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
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
---------------------------------------------------------------------- Jeremy Siek http://www.osl.iu.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------