首页 > 代码库 > C++ strcat(template)

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 };

 

C++ strcat(template)