Rootcint and vector<int[7]>

Hej,

I have problems with rootcint using the following class. It consists only of static vectors.

class A
{
static vector<int[7]> a
{
// vector filling
}
};

Using rootcint with
rootcint -f main.cc -c -p $(INCLUDEFLAGS) a.h

I get the error messages:
Error: class,struct,union or type int[7] not defined FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/memory LINE:29
Error: class,struct,union or type int[7] not defined FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/memory LINE:30
Error: class,struct,union or type int[7] not defined FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/memory LINE:31
Error: class,struct,union or type int[7] not defined FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/memory LINE:32
Error: class,struct,union or type int[7] not defined FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/memory LINE:33
Error: class,struct,union or type int[7] not defined FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/vector LINE:44
Error: Function int7 is not defined in current scope FILE:/opt/software/root_v4.00.02/cint/lib/prec_stl/vector LINE:316
Possible candidates are…
filename line:size busy function type and name
Warning: Error occured during reading source files
Warning: Error occured during dictionary source generation

thanks for your help,

Gernot

Hi Gernor,

CINT currently does not support STL containers a C style array.
Use the following simple work around:

class A { public: struct intarr { int val[7]; }; static std::vector<intarr> a; };
Or maybe even better, use a vector<vector >.

Cheers,
Philippe.

Hello.

:laughing:

None C++ compiler in the world should supoort std::vector<int[7]>. There are several reasons:

  1. There are copy-constructable/assignable requirements on the type of element. Array type is not copy constructable/assignable.

  2. What if I try to use, for example, resize???

void resize(size_type n, /attention/ T v = T());

T() expression is not possible for arrays.

For example

template
class A
{
public:
A(T t = T())
{
}
};

int main()
{
A<int[7]>a;
}

And comeau’s diagnostic :

“ComeauTest.c”, line 5: error: cast to type “int [7]” is not allowed
A(T t = T())
^
detected during instantiation of “A::A(T) [with T=int [7]]” at
line 12

And workaround with structure is good. The only thing, I can add to it is operator [], so we have two dimensional array :slight_smile:)

vec[0][0] etc.