User Defined Types

User Defined Types

The documentation says that I can have user defined types as long as I follow a few basic rules

  • The type has a public default constructor, copy constructor,
    assignment operator and non-virtual destructor. All of these functions
    must be either implicitly declared or behave as if they were implicitly
  • All non-static member variables of the types must be instances of
    Intel ArBB scalar types, container types, or other valid user-defined
  • If the type has any base classes, they must be valid user-defined types as well."

and then goes on to give an example that has no public default constructor, copy constructor,
assignment operator and non-virtual destructor and also uses just scalar types. Do you have any more complex examples ? None of the sample code uses UDTs.

Anyway, I plowed on and got this far creating a simple class of my own which compiles

class UDT1 {



UDT1(long long v10, long long v11,long long v12, long long v20, long long v21,long long v22) {
v1[0] = v10; v1[1] = v11; v1[2] = v12;
v2[0] = v20; v2[1] = v21; v2[2] = v22;
~UDT1() { return; }

const arbb::array<:u64> getV1() {return v1;}
const arbb::array<:u64> getV2() {return v2;}

arbb::array<:u64> v1;
arbb::array<:u64> v2;


until I add the following

ARBB_ELTWISE_METHOD_0(const arbb::array<:u64>,UDT1,getV1);

to try to list its methods. At this point I get the following error
test2.cpp:90:64: error: macro "ARBB_ELTWISE_METHOD_0" passed 4 arguments, but takes just 3
test2.cpp:90:1: error: ARBB_ELTWISE_METHOD_0 does not name a type

because obviously the macro is stealing the , I use in the return type and thinks its splitting two of
its arguments. Did I do something wrong? If I try to leave out the size of the return array it doesn't like
that eather . . .


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


The problem is because you have a comma in the return type of the macro. I'd suggest you use the following technique to make it work:

typedef arbb::array<:u64> Tuple3ul;
ARBB_ELTWISE_METHOD_0(const Tuple3ul, UDT1, getV1);

Actually, you can put the typedef before the definition of class UDT1 such that you can use the Tuple3ul type inside the class, saving you some typing. ;)


Ahhh, thanks, good idea. I'd realised the problem, if not the solution.

BTW, in
section Modules->Control Flow->Defines you have the following code snippet

 // Initialize i to zero, and keep incrementing until it reaches a million.
 _for(i32 i = 0, i I don't think you mean to have the ; after 100000 but rather a comma ?



Nice catch. It should have been a comma instead of a semicolon. We will have it fixed in the next revision of the online documentation.


Leave a Comment

Please sign in to add a comment. Not a member? Join today