I've been studying metaprogramming and reviewing many documents and code regarding boost files. What I've been trying to understand and accomplish is creating various types using
typedef,
template and
struct, similar to that of the boost files themselves, to create comparators. Ultimately, I want to be able to create a type that has sub-properties which can be further compareded and classified.
I apologize in advance as I cannot provide any working attempt at this. I am in the struggle.
Informal example:
create type
typedef int coordinate[3];
create standards - "typeless prototypes"
1 2 3
|
static const coordinate _x = {1,0,0};
static const coordinate _y = {0,1,0};
static const coordinate _z = {0,0,1};
| |
We "now have" three variables under one unique type. Now I want to wrap this further to work with other types (int, float, etc.).
create special cases
1 2 3 4 5 6 7
|
template<class ty, coordinate c> struct coord_type;
typedef coord_type<int,x> x_i;
typedef coord_type<float,x> x_f;
typedef coord_type<int,y> y_i;
typedef coord_type<float,y> y_f;
typedef coord_type<int,z> z_i;
typedef coord_type<float,z> z_f;
| |
declare more standards
1 2 3 4 5 6
|
const x_i i_i;
const x_f i_f;
const y_i j_i;
const y_f j_f;
const z_i k_i;
const z_f k_f;
| |
Where other variables can be represented based off this i,j,k standard and written in a more direct vector form.
And so on...
I don't know how helpful this is to those of you who are more experienced with this sort of style, but what I essintially would like to do is have
x,y,z variables act as standards for an i,j,k system that classify arbitrary variables of the coordinate type: Is the arbitrary variable i, j, or k? Is it defined as an int or float type?
Where arguments such as
sum_y = var1 + var2; are valid, provided:
sum_y is outputted as 6j, and
var1 and
var2 are 2j and 4j, respectively.
Please don't over-analyze what I have provided. Just focus on the concept I am bringing forward. I know that the examples above are rough, but I myself don't know all the ins and outs for how to approach this.
Thank you for your time. All help and suggestions are appreciated.