ããã°ã©ã ã®å¹çãé«ããããšãç®çãšããC ++ 11ã®é©æ°ã®1ã€ã¯ãSTLã³ã³ãããŒã®ã¡ãœããã®ãã¬ãŒã¹ãã¡ããªã§ãã ããšãã°ãstd :: vectorã§ã¯ãemplace_backã¡ãœããïŒã»ãŒpush_backã¡ãœããã®é¡äŒŒïŒãšemplaceã¡ãœããïŒã»ãŒinsertã¡ãœããã®é¡äŒŒïŒãç»å ŽããŸããã
ãããã®æ°ããã¡ãœããã®ç®çã瀺ãå°ããªäŸã次ã«ç€ºããŸãã
class MyKlass { public: MyKlass(int ii_, float ff_) {...} private: {...} }; some function { std::vector<MyKlass> v; v.push_back(MyKlass(2, 3.14f)); v.emplace_back(2, 3.14f); }
MyKlassã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ãŒãšãã¹ãã©ã¯ã¿ãŒã®åŒã³åºãã«åŸããšãpush_backåŒã³åºãäžã«æ¬¡ã®ããšãããããŸãã
- æåã«ãã¯ã©ã¹MyKlassã®äžæãªããžã§ã¯ãã®ã³ã³ã¹ãã©ã¯ã¿ãŒãå®è¡ãããŸã
- 次ã«ããã¯ã¿ãŒå ã«çŽæ¥é 眮ããããªããžã§ã¯ãã«å¯ŸããŠã移åã³ã³ã¹ãã©ã¯ã¿ãŒãåŒã³åºãããŸãïŒMyClassã§å®çŸ©ãããŠããå Žåãå®çŸ©ãããŠããªãå Žåãã³ããŒã³ã³ã¹ãã©ã¯ã¿ãŒãåŒã³åºãããŸãïŒ
- äžæãªããžã§ã¯ããã¹ãã©ã¯ã¿
ã芧ã®ããã«ãpush_backã¡ãœããã«æž¡ããããªããžã§ã¯ãã¯æããã«å³èŸºå€åç §ã§ããããã®åŒãå®è¡ãããçŽåŸã«ç Žæ£ããããããéåžžã«å€ãã®äœæ¥ãè¡ãããŠããŸããããã®å€ãã¯ããã»ã©å¿ èŠãããŸããã ãããã£ãŠãäžæãªããžã§ã¯ããäœæããã³ç Žæ£ããçç±ã¯ãããŸããã ãã®å Žåããã¯ã¿ãŒã®ããå åŽã«ãªããžã§ã¯ããäœæããªãã®ã¯ãªãã§ããïŒ ããã¯ãŸãã«emplace_backã¡ãœãããè¡ãããšã§ãã äŸv.emplace_backïŒ2ã3.14fïŒã®åŒã§ã¯ã1ã€ã®ã³ã³ã¹ãã©ã¯ã¿ãŒã®ã¿ãå®è¡ããããã¯ã¿ãŒå ã«ãªããžã§ã¯ããäœæãããŸãã äžæãªããžã§ã¯ãã䜿çšããŸããã emplace_backèªäœãMyKlassã®ã³ã³ã¹ãã©ã¯ã¿ãŒãåŒã³åºããå¿ èŠãªåŒæ°ãããã«æž¡ããŸãã ãã®åäœã¯ãC ++ 11ã®2ã€ã®é©æ°ã«ãã£ãŠå¯èœã«ãªããŸãããå¯å€æ°ã®åŒæ°ãæã€ãã³ãã¬ãŒãïŒå¯å€ã¢ãã€ã³ãã³ãã¬ãŒãïŒãšçæ³çãªéä¿¡ïŒå®å šè»¢éïŒã§ãã ãã®èšäºã§ã¯ãå®ç§ãªäŒéãã©ã®ããã«æ©èœããã©ã®ããã«äœ¿çšãããã説æããŸãã
å®å šãªäŒéåé¡
ã¿ã€ãE1ãE2ã...ãEnã®ãã©ã¡ãŒã¿ãŒãåãåãfuncé¢æ°ããããšããŸãã åããã©ã¡ãŒã¿ãŒã®ã»ãããåãå ¥ããã©ãããŒé¢æ°ãäœæããå¿ èŠããããŸãã èšãæãããšãäžæå€æ°ãäœæããã«åä¿¡ãããã©ã¡ãŒã¿ãŒãå¥ã®é¢æ°ã«æž¡ãé¢æ°ãå®çŸ©ãããã€ãŸãçæ³çãªè»¢éãå®è¡ããŸãã
åé¡ãç¹å®ããã«ã¯ãäžèšã§èª¬æããemplace_backã¡ãœãããæ€èšããŠãã ããã vector :: emplace_backã¯ãTãäœã§ããããäœãç¥ããã«ããã®ãã©ã¡ãŒã¿ãŒãTã³ã³ã¹ãã©ã¯ã¿ãŒã«æž¡ããŸãã
次ã®ã¹ãããã§ã¯ãC ++ 11ã®é©æ°ã䜿çšããã«ãã®åäœãå®çŸããæ¹æ³ã瀺ãããã€ãã®äŸãæ€èšããŸãã ç°¡åã«ããããã«ãå¯å€æ°ã®åŒæ°ãã©ã¡ãŒã¿ãŒãæã€ãã³ãã¬ãŒãã䜿çšããå¿ èŠæ§ãèæ ®ããŸãã; 2ã€ã®åŒæ°ã®ã¿ãå¿ èŠã§ãããšä»®å®ããŸãã
é ã«æµ®ãã¶æåã®ãªãã·ã§ã³ïŒ
template <typename T1, typename T2> void wrapper(T1 e1, T2 e2) { func(e1, e2); }
ããããã©ãããŒã¯å€ã«ãã£ãŠãã©ã¡ãŒã¿ãŒãåãå ¥ãããããfuncãåç §ã«ãã£ãŠãã©ã¡ãŒã¿ãŒãåãå ¥ããå Žåãããã¯æããã«å¿ èŠã«å¿ããŠæ©èœããŸããã ãã®å Žåãfuncãåç §ã«ãã£ãŠåãåã£ããã©ã¡ãŒã¿ãŒãå€æŽããŠããã©ãããŒã«æž¡ããããã©ã¡ãŒã¿ãŒã«ã¯åœ±é¿ããŸããïŒã©ãããŒå ã§äœæãããã³ããŒã¯å€æŽãããŸãïŒã
ããã§ã¯ãåç §ã«ãã£ãŠãã©ã¡ãŒã¿ãŒãåãå ¥ããããã«ã©ãããŒãããçŽãããšãã§ããŸãã funcãåç §ã§ã¯ãªãå€ã§åãå ¥ããããå Žåãããã¯é害ã«ãªããŸãããã©ãããŒå ã®funcã¯ããèªäœã«å¿ èŠãªã³ããŒãäœæããããã§ãã
template <typename T1, typename T2> void wrapper(T1& e1, T2& e2) { func(e1, e2); }
å¥ã®åé¡ããããŸãã å³èŸºå€ãåç §ãšããŠé¢æ°ã«æž¡ãããšã¯ã§ããŸããã ãããã£ãŠãå®å šã«ç°¡åãªåŒã³åºãã¯ã³ã³ãã€ã«ãããŸããã
wrapper(42, 3.14f); // : rvalue- wrapper(i, foo_returning_float()); //
ãããŠããããã®ãªã³ã¯ãäžå®ã«ãããšããã¢ã€ãã¢ãçãŸããå Žåãããã«åé¡ã¯è§£æ±ºããŸããã funcã§ã¯ããã©ã¡ãŒã¿ãŒãšããŠéå®æ°ã®åç §ãå¿ èŠã«ãªãå Žåãããããã§ãã
æ®ã£ãŠããã®ã¯ãããã€ãã®ã©ã€ãã©ãªã§äœ¿çšãããŠããç²éãªã¢ãããŒãã§ãïŒäžå®ã®éå®æ°ãªã³ã¯ã®é¢æ°ããªãŒããŒããŒãããã«ã¯ïŒ
template <typename T1, typename T2> void wrapper(T1& e1, T2& e2) { func(e1, e2); } template <typename T1, typename T2> void wrapper(const T1& e1, T2& e2) { func(e1, e2); } template <typename T1, typename T2> void wrapper(T1& e1, const T2& e2) { func(e1, e2); } template <typename T1, typename T2> void wrapper(const T1& e1, const T2& e2) { func(e1, e2); }
ææ°é¢æ°çæé·ã å®éã®é¢æ°ã®ããã€ãã®åççãªéã®ãã©ã¡ãŒã¿ãŒãåŠçããå¿ èŠããããšãã«ãã©ãã ãã®æ¥œãã¿ããããããããæ³åã§ããŸãã ããã«æªãããšã«ãC ++ 11ã¯å³èŸºå€ãªã³ã¯ãè¿œå ããŸããããããã©ãããŒé¢æ°ã§èæ ®ããå¿ èŠããããããã¯æããã«æ¡åŒµå¯èœãªãœãªã¥ãŒã·ã§ã³ã§ã¯ãããŸããã
å³èŸºå€ãªã³ã¯ã®ãªã³ã¯å§çž®ãšç¹å¥ãªåæšè«
C ++ 11ã§å®å šãªè»¢éãã©ã®ããã«å®è£ ããããã説æããã«ã¯ããŸããã®ããã°ã©ãã³ã°èšèªã«è¿œå ããã2ã€ã®æ°ããã«ãŒã«ãç解ããå¿ èŠããããŸãã
ç°¡åãªãã®ããå§ããŸããã-ãªã³ã¯ã®åŽ©å£ã ãåç¥ã®ããã«ãC ++ã§ã®ãªã³ã¯ãžã®ãªã³ã¯ã®ååŸã¯èš±å¯ãããŠããŸãããããã³ãã¬ãŒããå®è£ ãããŠããå Žåã«ãããçºçããããšããããŸãã
template <typename T> void baz(T t) { T& k = t; }
ãã®é¢æ°ã次ã®ããã«åŒã³åºããšã©ããªããŸããïŒ
int ii = 4; baz<int&>(ii);
ãã³ãã¬ãŒããã€ã³ã¹ã¿ã³ã¹åãããšããTã¯intïŒã«èšå®ãããŸãã é¢æ°å ã®å€æ°kã¯ã©ã®åã«ãªããŸããïŒ ã³ã³ãã€ã©ãŒã¯intïŒïŒããåç §ãããŸãããããã¯çŠæ¢ãããæ§é ã§ãããããã³ã³ãã€ã©ãŒã¯ãããéåžžã®ãªã³ã¯ã«å€æããã ãã§ãã å®éãC ++ 11以åã§ã¯ããã®åäœã¯æšæºåãããŠããŸããã§ããããå€ãã®ã³ã³ãã€ã©ã¯ã¡ã¿ããã°ã©ãã³ã°ã§ããèŠãããããããã®ãããªã³ãŒããåãå ¥ããŠå€æããŸããã C ++ 11ã§å³èŸºå€ãªã³ã¯ãè¿œå ãããåŸãããŸããŸãªã¿ã€ãã®ãªã³ã¯ãçµã¿åããããšãã®åäœã決å®ããããšãéèŠã«ãªããŸããïŒããšãã°ãint &&ïŒ??ã®æå³ïŒã
ããã§ããªã³ã¯å§çž®ã®ã«ãŒã«ãç»å ŽããŸããã ãã®ã«ãŒã«ã¯éåžžã«åçŽã§ã-1ã€ã®ã¢ã³ããµã³ãïŒïŒïŒãåžžã«åªå ãããŸãã ãããã£ãŠ-ïŒïŒãšïŒïŒã¯ïŒïŒïŒãïŒ&&ãšïŒïŒãããã³ïŒïŒãš&&ïŒã§ãã å§çž®ã®çµæãïŒ&&ïŒã«ãªãã®ã¯ïŒ&&ããã³&&ïŒã®ã¿ã§ãã ãã®ã«ãŒã«ã¯ãïŒã1ã§&&ã0ã®è«çORçµæãšæ¯èŒã§ããŸãã
ãã®ãããã¯ã«çŽæ¥é¢é£ãããã1ã€ã®C ++ã®è¿œå ã¯ãããŸããŸãªå Žåã®å³èŸºå€ãªã³ã¯ã®ç¹å¥ãªåã®æšè«èŠåã§ã[1]ã ãã³ãã¬ãŒãé¢æ°ã®äŸãèããŠã¿ãŸãããã
template <class T> void func(T&& t) { }
äºéã¢ã³ããµã³ãã«ã ãŸãããªãã§ãã ãããããã§ã¯tã¯å³èŸºå€åç §ã§ã¯ãããŸãã[2]ã ãã®ç¶æ³ã§è¡šç€ºãããå ŽåïŒç¹å¥ãªåæšè«ãå¿ èŠãªå ŽåïŒãT &&ã¯ç¹å¥ãªæå³ãæã¡ãŸã-funcãã€ã³ã¹ã¿ã³ã¹åããããšãTã¯æž¡ãããåã«å¿ããŠå€åããŸãã ã¿ã€ãUã®å·ŠèŸºå€ãæž¡ãããå ŽåãTã¯UïŒã«ãªããŸãã Uãå³èŸºå€ã®å ŽåãTã¯ã¡ããã©Uã«ãªããŸããäŸïŒ
func(4); // 4 rvalue: T int double d = 3.14; func(d); // d lvalue; T double& float f() {...} func(f()); // f() rvalue; T float int bar(int i) { func(i); // i lvalue; T int& }
ãã®èŠåã¯çãããå¥åŠã«ããæãããããããŸããã ããã§ãã ããããããã«ããããããããã®ã«ãŒã«ãå®å šãªéä¿¡ã®åé¡ã解決ããã®ã«åœ¹ç«ã€ããšãç解ããããšã«ãªããšããã®ã«ãŒã«ã¯éåžžã«æçœã«ãªããŸãã
std :: forwardã䜿çšããŠå®å šãªè»¢éãå®è£ ãã
次ã«ãäžèšã®ã©ãããŒãã³ãã¬ãŒãé¢æ°ã«æ»ããŸãããã C ++ 11ã䜿çšããŠå®è£ ããæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
template <typename T1, typename T2> void wrapper(T1&& e1, T2&& e2) { func(forward<T1>(e1), forward<T2>(e2)); }
ãããŠãããã«[3]ãã©ã®ããã«å®è£ ãããŠãããã瀺ããŸãã
template<class T> T&& forward(typename std::remove_reference<T>::type& t) noexcept { return static_cast<T&&>(t); }
次ã®åŒã³åºããæ€èšããŠãã ããã
int ii ...; float ff ...; wrapper(ii, ff);
æåã®åŒæ°ïŒ2çªç®ãåæ§ïŒãèããŠã¿ãŸãããïŒiiã¯å·ŠèŸºå€ã§ãããããT1ã¯ç¹å¥ãªåæšè«ã®èŠåã«åŸã£ãŠintïŒã«ãªããŸãã çµæã¯funcã®åŒã³åºãã§ãïŒforward <intïŒ>ïŒe1ïŒã...ïŒã ãããã£ãŠããã©ã¯ãŒããã¿ãŒã³ã¯intïŒåã«ãã£ãŠã€ã³ã¹ã¿ã³ã¹åããããã®é¢æ°ã®æ¬¡ã®ããŒãžã§ã³ãååŸããŸãã
int& && forward(int& t) noexcept { return static_cast<int& &&>(t); }
ãªã³ã¯å§çž®ã«ãŒã«ãé©çšããæéïŒ
int& forward(int& t) noexcept { return static_cast<int&>(t); }
èšãæããã°ãåŒæ°ã¯ã巊蟺å€ã®èŠæ±ã«å¿ããŠãåç §ã«ãã£ãŠfuncã«æž¡ãããŸãã
次ã®äŸïŒ
wrapper(42, 3.14f);
ããã§ãåŒæ°ã¯å³èŸºå€ã§ãããããT1ã¯intã«ãªããŸãã funcãåŒã³åºããŸãïŒforwardïŒe1ïŒã...ïŒã ãããã£ãŠããã©ã¯ãŒããã³ãã¬ãŒãé¢æ°ã¯intåã«ãã£ãŠã€ã³ã¹ã¿ã³ã¹åããã次ã®ããŒãžã§ã³ã®é¢æ°ãååŸããŸãã
int&& forward(int& t) noexcept { return static_cast<int&&>(t); }
åç §ã«ãã£ãŠååŸãããåŒæ°ã¯ãå³èŸºå€åç §ã«å€æãããŸããããã¯ãåæ¹ããåãåãããã«å¿ èŠãªãã®ã§ãã
Tãå ¥ååŒæ°ã®ã¿ã€ãïŒå·ŠèŸºå€ãŸãã¯å³èŸºå€ïŒã«å¿ããŠå€UïŒãŸãã¯U &&ããšãããšãã§ããå Žåãforwardãã³ãã¬ãŒãé¢æ°ã¯static_cast <T &&>ïŒtïŒã®äžçš®ã®ã©ãããŒãšèŠãªãããšãã§ããŸãã ã©ãããŒã¯ãåŒæ°ã¿ã€ãã®ä»»æã®çµã¿åãããåŠçãã1ã€ã®ãã³ãã¬ãŒãã§ãã
ãã©ã¯ãŒããã³ãã¬ãŒãé¢æ°ã¯ãC ++ 11ã®stdåå空éã®ããããŒãã¡ã€ã«ããŠãŒãã£ãªãã£ãã«å®è£ ãããŠããŸãã
å¥ã®æ³šæç¹ïŒstd :: remove_referenceã䜿çšããŸãã å®éããã®é¢æ°ã䜿çšããã«forwardãå®è£ ã§ããŸãã ãªã³ã¯å§çž®ã¯ãã¹ãŠã®äœæ¥ãè¡ãã®ã§ãstd :: remove_referenceã䜿çšããããšã¯ãã®ããã«åé·ã§ãã ãã ãããã®é¢æ°ã䜿çšãããšããã®ã¿ã€ããæšæž¬ã§ããªãç¶æ³ïŒC ++æšæº14.8.2.5ã«ããïŒã§TïŒtãåºåã§ãããããstd :: forwardãåŒã³åºããšãã«ãã³ãã¬ãŒããã©ã¡ãŒã¿ãŒãæ瀺çã«æå®ããå¿ èŠããããŸãã
ãŠãããŒãµã«ãªã³ã¯
圌ã®ã¹ããŒããããã°æçš¿ãããã³æ¬ã®äžã§ãScott Myersã¯ãåæšè«ã®ã³ã³ããã¹ãã«ããå³èŸºå€ãªã³ã¯ã«ããŠãããŒãµã«ãªãã¡ã¬ã³ã¹ããšããååãä»ããŠããŸãã ãã®ååãæåãããã©ãããèšãã®ã¯é£ããã§ãã ç§ã«é¢ããŠã¯ãæ°ããæ¬ãEffective C ++ãããã®ãããã¯ã«é¢ããç« ãåããŠèªãã ãšããæ··ä¹±ããŸããã å€ããå°ãªãããåºç€ãšãªãã¡ã«ããºã ïŒãªã³ã¯å§çž®ãšç¹å¥ãªåæšè«èŠåïŒãç解ãããšãã«ããã¹ãŠãæããã«ãªããŸããã
ãã£ããã¯ããæ®éçãªåç §ã[4]ãšãããã¬ãŒãºã¯ããåæšè«ã®æèã«ãããå³èŸºå€ãªã³ã¯ãããã確ãã«ç°¡æœã§çŸãããšããããšã§ãã ãã ããã³ãŒããæ¬åœã«ç解ãããå Žåã¯ãå®å šãªèª¬æãé¿ããããšã¯ã§ããŸããã
å®å šãªäŒéã®äŸ
å®å šãªäŒéã¯ãããé«ãã¬ãã«ã§ã®ããã°ã©ãã³ã°ãå¯èœã«ãããããéåžžã«äŸ¿å©ã§ãã é«éé¢æ°ã¯ãä»ã®é¢æ°ãåŒæ°ãšããŠäœ¿çšããããããããè¿ãããšãã§ããé¢æ°ã§ãã å®å šãªãã¹ããªããšãã©ãããŒé¢æ°å ã®é¢æ°ã«åŒæ°ãæž¡ã䟿å©ãªæ¹æ³ããªããããé«æ¬¡é¢æ°ãé©çšããããšã¯éåžžã«è² æ ã«ãªããŸãã ããã§ã®ãé¢æ°ããšããçšèªã¯ãé¢æ°èªäœã«å ããŠãã³ã³ã¹ãã©ã¯ã¿ãŒãå®éã«ã¯é¢æ°ã§ãããã¯ã©ã¹ãæå³ããŸãã
ãã®èšäºã®åé ã§ãemplace_backã³ã³ãããŒã¡ãœããã«ã€ããŠèª¬æããŸããã å¥ã®è¯ãäŸã¯ã åã®èšäºã§èª¬æããæšæºãã³ãã¬ãŒãé¢æ°make_uniqueã§ãã
template<typename T, typename... Args> unique_ptr<T> make_unique(Args&&... args) { return unique_ptr<T>(new T(std::forward<Args>(args)...)); }
ãã®èšäºã§ã¯ãå¥åŠãªäºéã¢ã³ããµã³ããåã«ç¡èŠããå¯å€æ°ã®ãã³ãã¬ãŒãåŒæ°ã«çŠç¹ãåãããããšãæ£çŽã«èªããŠããŸãã ããããä»ã§ã¯ã³ãŒããå®å šã«ç解ããã®ã¯å®å šã«ç°¡åã§ãã èšããŸã§ããªããçæ³çãªãã¹ãšå¯å€æ°ã®åŒæ°ãæã€ãã³ãã¬ãŒãã¯éåžžã«é »ç¹ã«äžç·ã«äœ¿çšãããŸããã»ãšãã©ã®å Žåããããã®åŒæ°ãæž¡ãé¢æ°ãŸãã¯ã³ã³ã¹ãã©ã¯ã¿ãŒãããã€ã®åŒæ°ãåãå ¥ãããããããªãããã§ãã
çæ³çãªè»¢éãã¯ããã«è€éã«äœ¿çšããäŸãšããŠãstd :: bindã®å®è£ ãèŠãããšãã§ããŸãã
ãœãŒã¹ãžã®åç §
çŽ æã®æºåã§ç§ã倧ãã«å©ããããã€ãã®æ å ±æºã¯æ¬¡ã®ãšããã§ãã
- Bjarne Stroustrupã«ãããThe C ++ Programming Languageãã®ç¬¬4ç
- Scott Myersã«ããæ°ãããEffective Modern C ++ãã ãã®æ¬ã§ã¯ãããŠãããŒãµã«ãªã³ã¯ãã«ã€ããŠè©³ãã説æããŠããŸãã å®éããã®æ¬ã®5åã®1以äžããã®ãããã¯ã«åœãŠãããŠããŸãã
- ãã¯ãã«ã«ããŒããŒn1385 ïŒã転éã®åé¡ïŒåŒæ°ãã
- Thomas Becker C ++ Rvalueã®ãªãã¡ã¬ã³ã¹ã®èª¬æ -åªããèšè¿°ãšéåžžã«æçšãªèšäº
泚ïŒ
[1] autoããã³decltypeã䜿çšã§ããŸããããã§ã¯ããã³ãã¬ãŒãã䜿çšããå Žåã®ã¿ã説æããŸãã
[2]å³èŸºå€ãªã³ã¯ïŒãªãŒããŒããŒã&&ïŒã®è¡šèšæ³ãéžæããªããšããC ++æšæºåå§å¡äŒã®æ±ºå®ã倱æãããšèããŸãã ã¹ã³ããã»ãã€ã€ãŒãºã¯åœŒã®ã¹ããŒãã®äžã§èªããïŒãããŠåœŒã®ããã°ã«å°ãã³ã¡ã³ãããïŒ3幎åŸããã®è³æã¯ãŸã åŠã¶ã®ãç°¡åã§ã¯ãªãããšãèªããã ãããŠããThe C ++ Programming Languageãã®ç¬¬4çã®BjörnStraustrupã¯ãstd :: forwardã説æãããšãã«ããã³ãã¬ãŒãåŒæ°ã®æ瀺çãªæ瀺ãå¿ããŠããŸããã ããã¯ç¢ºãã«ããªãé£ããé åã§ãããšçµè«ä»ããããšãã§ããŸãã
[3]ããã¯ãSTL C ++ 11ãã転éãããstd ::ã®ç°¡æããŒãžã§ã³ã§ãã å³èŸºå€åŒæ°ã®ããã«æ瀺çã«ãªãŒããŒããŒããããè¿œå ããŒãžã§ã³ããŸã ãããŸãã ç§ã¯ãŸã ãããå¿ èŠãªçç±ã解æããããšããŠããŸãã äœãã¢ã€ãã¢ãããã°æããŠãã ããã
[4]転éåç §ã¯ãç§ãåºããããå¥ã®æå®ã§ãã
翻蚳è ããïŒCppCon2014ã§ã¯ãå€ãã®äººïŒãã€ã€ãŒãºãã¹ãã©ãŠã¹ãã«ãããµãã¡ãŒãå«ãïŒãã ãŠãããŒãµã«åç §ã§ã¯ãªã転éåç §ãšããçšèªã䜿çšããããšã«ããŸããã
ãã®ãããã¯ã«é¢ããhabrã«é¢ããèšäºïŒ
å³èŸºå€ãªã³ã¯ã®ç°¡åãªçŽ¹ä»
C ++ 11ãŸãã¯T &&ã®ããŠãããŒãµã«ãåç §ã¯ãå¿ ããããå³èŸºå€åç §ããæå³ããããã§ã¯ãããŸãã