Home > Back-end >  Why can't C pair, element of the tuple type is a reference type?
Why can't C pair, element of the tuple type is a reference type?

Time:04-26

Excuse me, why pair, element of the tuple type is not a reference type, but can be a normal class type and pointer types? P1 insert element, what will happen, copy construction string object?
 
Pair P1.//no error
Pair The p2.//no error
Pair P3;//error

CodePudding user response:

Can.
 
int a;
STD: : pair Ar={a, 1};

CodePudding user response:

Want to know what is reference, what are the characteristics of reference and reference can exist independently? Look at the source code, they should be clear
  • Related