Hi there, the C++ standard (section 20.2) defines std::make_pair() as:
template <class T1, class T2>
pair<T1, T2> make_pair(const T1& x, const T2& y);
On my system (.NET 2003) it is defined as:
template<class _Ty1, class _Ty2> inline
pair<_Ty1, _Ty2> __cdecl make_pair(_Ty1 _Val1, _Ty2 _Val2)
{
// return pair composed from arguments
return (pair<_Ty1, _Ty2>(_Val1, _Val2));
}
In particular, not that the arguments _Val1 and _Val2 are passed in by
value, and not by reference.
Is this a bug in the .NET library? or is this actually allowed by the
spec? 3 3435 ma***********@perform-sol.com wrote: Hi there, the C++ standard (section 20.2) defines std::make_pair() as:
template <class T1, class T2> pair<T1, T2> make_pair(const T1& x, const T2& y);
On my system (.NET 2003) it is defined as:
template<class _Ty1, class _Ty2> inline pair<_Ty1, _Ty2> __cdecl make_pair(_Ty1 _Val1, _Ty2 _Val2) { // return pair composed from arguments return (pair<_Ty1, _Ty2>(_Val1, _Val2)); }
In particular, not that the arguments _Val1 and _Val2 are passed in by value, and not by reference.
Is this a bug in the .NET library? or is this actually allowed by the spec?
That was changed in the 2003 revision of the standard. It now says
template < class T1 , class T2 > pair <T1 , T2 > make_pair (T1 x , T2 y ); 7 Returns: pair<T1, T2>(x, y).
--
Pete Becker
Dinkumware, Ltd. ( http://www.dinkumware.com)
very interesting - what is the reason for this change? ma***********@perform-sol.com wrote: very interesting - what is the reason for this change?
make_pair("abc", 3);
used to be illegal, because the first argument creates a reference to an
array, which can't be copied. With the new version the type of the first
argument decays to pointer to const char.
--
Pete Becker
Dinkumware, Ltd. ( http://www.dinkumware.com) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tanguy Fautré |
last post by:
Hello,
does std::multimap make any guarantee about the insertion order?
for example:
int main()
{
std::multimap<int, int> Map;
|
by: JustSomeGuy |
last post by:
in the stl map class I see the use of a function pair and make_pair.
What is the difference between pair and make_pair?
dictionary.insert(std::pair<Key, Value>(k,v));
works as well as:
...
|
by: Flzw |
last post by:
Well I have a map like this :
std::map <string, CObject> ObjectList;
I have a function like this :
CObject* NewObject( char* Name, CArg* Arg)
{
std::string key = Name;
ObjectList =...
|
by: John Black |
last post by:
Hi,
I have this code piece,
vector<int> v1, v2;
vector<pair<int, int> > uups;
....
transform(v1.begin(), v1.end(), v2.begin(), uups.end(),
ptr_fun(make_pair));
|
by: Erik Wikström |
last post by:
First of all, forgive me if this is the wrong place to ask this question,
if it's a stupid question (it's my second week with C++), or if this is
answered some place else (I've searched but not...
|
by: Jim Langston |
last post by:
Expected output of program:
Key is: 0 String is: Hello
Key is: 1 String is: Goodbye
Key is: 2 String is: The end
Actual output:
Key is: 0 String is: The End
Key is: 1 String is:
Key is: 2...
|
by: desktop |
last post by:
I have made this little test with std::pair:
test<intt1(1);
test<intt2(2);
std::pair<test<int>,test<int mypair = std::make_pair(t1,t2);
where test is a template class I wrote. It seems a bit...
|
by: subramanian100in |
last post by:
Given two types T1 and T2, we can create
pair<T1, T2p(value1, value2);
where value1 and value2 are of types T1 and T2 respectively.
Suppose we want to assign a new pair<value to p. We can do...
|
by: guido |
last post by:
Hi,
I'm looking for a container class that can map whole ranges of keys to
objects - something like std::map, but not only for individual values for
the key, but for whole ranges.
Example:
I...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |