c++ - Is this a legitimate method for making sure implicit type conversion does not happen -
is legitimate method making sure implicit type conversion not happen?
#include <string> #include <iostream> void func(std::string s) { std::cout << "thanks string\n"; } template<class t> void func(t)=delete; int main() { func("test1"); // str.cc: in function ‘int main()’: // str.cc:13:16: error: utilize of deleted function ‘void func(t) [with t = const char*]’ // func("test1"); // ^ // str.cc:9:6: error: declared here // void func(t)=delete; // ^ // func(std::string("test2")); homecoming 0; }
looks me.
it same thing answers.
c++ c++11
No comments:
Post a Comment