K
K. Frank
Hello Group!
As a simple example, consider:
int i = 3;
int j = 4;
auto p1 = std::make_pair (i, j); // no explicit types
auto p2 = std::make_pair<int, int> (i, j); // explicit
The reason I ask is because some time ago, I tried
explicitly instantiating make_pair (in a more complicated
setting, the details of which I don't recall, but I
think it involved iterators for a template collection
class), and I couldn't get it to work -- I got all kinds
of confusing template compiler error messages. Then I
"wised up" and just called make_pair without giving it
explicit types, and everything worked fine.
But now I see some sample code (on www.cplusplus.com)
where make_pair is used with explicit types. So what's
the right way to use make_pair, and what's the right
way to think about what's going on?
Thanks.
K. Frank
As a simple example, consider:
int i = 3;
int j = 4;
auto p1 = std::make_pair (i, j); // no explicit types
auto p2 = std::make_pair<int, int> (i, j); // explicit
The reason I ask is because some time ago, I tried
explicitly instantiating make_pair (in a more complicated
setting, the details of which I don't recall, but I
think it involved iterators for a template collection
class), and I couldn't get it to work -- I got all kinds
of confusing template compiler error messages. Then I
"wised up" and just called make_pair without giving it
explicit types, and everything worked fine.
But now I see some sample code (on www.cplusplus.com)
where make_pair is used with explicit types. So what's
the right way to use make_pair, and what's the right
way to think about what's going on?
Thanks.
K. Frank