C++ strcat(template版本)

 1 template<unsigned N, unsigned M>
 2 inline std::shared_ptr<char> strcat(const char (&p1)[N], const char (&p2)[M])
 3 {
 4     std::shared_ptr<char> s1(new char[N]);
 5     char s2[M];
 6     std::strcpy(s1.get(), p1);
 7     std::strcpy(s2, p2);
 8     std::strcat(s1.get(), s2);
 9     return s1;
10 };

 

posted @ 2017-07-21 13:24  FeckCode  阅读(254)  评论(0编辑  收藏  举报