'std::pair constructor interface
It's actually a general question about interface design, but it's easier for me to just take std::pair as an example:
template <class T1, class T2>
struct pair {
...
pair(const T1& x, const T2& y);
template<class U, class V> pair(U&& x, V&& y);
...
};
So we can see there are two overloads that both take 2 arguments to initialize the 2 members of the pair. My question is, what is the benefit of providing the first one while the second one is available? Are there any types of arguments that can only be passed to the first one but not the second one?
(Let's just put aside the standard library's consideration for backward compatibility for a while, and discuss the interface design as a general question.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
