Function resolution

How can I make something like this:

1
2
DoSomething(int x, int y, int z, int t, int y, int u);
DoSomething(int x, int y, int t, int y, int u, int p);


Hello.

How can I make the compiler choose the function with no "z" but with "p"?

I know I can make them into classes:

1
2
DoSomething(Class1(x, y, z), Class2(t, y, u));
DoSomething(Class3(x, y), Class4(t, y, u, p));


I can also make them into names of different functions:

1
2
DoSomething1()
DoSomething2()


I can use namespaces to separate the functions.

But what I want is:
1
2
3
4
DoSomething(Object1(x, y, z), Object2(t, y, u))
{
     use x, y, z, t, y, u without going through Object1 and Object2;
}


Basically I am looking for a construct that will not make an instance of an object in order to make a distinction between the two functions. I do not want to read values from a file with millions of lines and create unnecessary objects just to use the correct function.

Is there a construct using lamdas or templates or macros that can expand the expression Object1(x, y, z) and Object2(t, y, u) on compile time to just
DoSomething(x, y, z, t, y, u)? This is in order to avoid unnecessary memory allocations and speed up my program.

I do not want to store them in object 'a'. I want to pass them to the right function without making an object. Think of it as the object being there just to wrap the parameters but it should not be created thus no memory should be allocated for it and no time should be spent on making it during runtime.

Note: I have a lot of functions DoSomething so it is not about just these two.

Thanks in advance.
Last edited on
I do not want to read values from a file with millions of lines (...) just to use the correct function.
¿? I guess that you mean at runtime, so I don't understand you.

I don't see why accessing 'x' will be faster than 'a.x'

[code]"And please use code tags"[/code]
Last edited on
I do not want to store them in object 'a'. I want to pass them to the right function without making an object. Think of it as the object being there just to wrap the parameters but it should not be created thus no memory should be allocated for it and no time should be spent on making it during runtime.

Updated the main post.
Last edited on
Topic archived. No new replies allowed.