コンパイルエラーになる原因を教えてください。
コンパイラー: VC++ 2015
C++
1// main.cpp 2#include "sub.h" 3#include <iostream> 4#include <string> 5 6int main() { 7 std::string string0("test"); 8 std::cout << GetLength(string0) << std::endl; 9 10 const char* string1 = "test"; 11 std::cout << GetLength(string1) << std::endl; 12}
C++
1// sub.h 2#ifndef SUB_H 3#define SUB_H 4 5#include <string> 6 7template <typename type> 8std::size_t GetLength(const type& string) { 9 return string.length(); 10} 11 12template <> 13std::size_t GetLength<char*>(const char*& string) { 14 return std::strlen(string); 15} 16 17#endif
エラーメッセージ エラー (アクティブ) 指定された型と一致する 関数テンプレート "GetLength" のインスタンスはありません エラー C2912 明示的な特殊化 'size_t GetLength<char*>(const char *&)' は関数テンプレートの特殊化ではありません エラー C2912 明示的な特殊化 'size_t GetLength<char*>(const char *&)' は関数テンプレートの特殊化ではありません

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/11 12:50 編集
2016/02/11 12:55 編集
2016/02/11 13:38