KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why can't you pass literal strings in here? I made it work with a very slight workaround. template<const char* ptr> struct lols { lols() : i(ptr) {} std::string i; }; class file { public: static const char arg[]; }; decltype(file::arg) file::arg = __FILE__; // Getting the right type declaration for this was irritating, so I C++0xed it. int main() { // lols<__FILE__> hi; // Error: A template argument may not reference a non-external entity lols<file::arg> hi; // Perfectly legal std::cout << hi.i; std::cin.ignore(); std::cin.get(); }
Tags (comma-separated)
Save Edits
Cancel