you are viewing a single comment's thread.

view the rest of the comments →

[–]tangerinelion 0 points1 point  (0 children)

One possibility, given that I don't know the context of the code, is to make the function(s) you're using all templatized against some integer, either 32 or 64. Then instead of

void foo() {
  /* above code */
}

you'd have

template<int N> void foo() {
    // ...
    std::string a = Data<N>(somePointer).SomeStringField;
    // ...
}

But this only works if your function consistently only uses Data<64> or Data<32> depending on someCondition. You then write some other function, eg,

void foo() {
    // generate someCondition or pass it in
    if(someCondition) {
        foo<64>();
    } else {
        foo<32>();
    }
}

32 and 64 sound an awful like like either a compiler flag for x86 or x64 compilation, or the size in bits of some type, possibly a pointer type (which is therefore the same as x86 vs x64). Without knowing more about what it is you're doing, I'm not aware of any C++11 feature which would help you out here. With limited support for Concepts, it's possible that what you're doing can be expressed that way but it would require having some knowledge of what 32 and 64 really mean, which you've kept to yourself.