Reputation: 1062
Is it safe to define the following two methods in C++ and use them without risk of them being mixed up in runtime?
void map(float (&a)[10], const double (&b)[6]);
void map(float (&a)[10], const double (&b)[3]);
or
void map(double (&a)[6], const float (&b)[10]);
void map(double (&a)[3], const float (&b)[10]);
They compile ok, so I figured their signature should be different and everything would be fine. However, I'm currently experiencing memory problems, so I want to make sure.
Upvotes: 1
Views: 92
Reputation: 133024
Yes, it is perfectly safe. Moreover, your sentence
without risk of them being mixed up in runtime?
makes absolutely no sense because overload resolution takes place compile-time.
Upvotes: 2