Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ VS 2010没有';检测不到模板内代码的任何更改_C++_Visual Studio 2010 - Fatal编程技术网

C++ VS 2010没有';检测不到模板内代码的任何更改

C++ VS 2010没有';检测不到模板内代码的任何更改,c++,visual-studio-2010,C++,Visual Studio 2010,假设我已经在头文件中编写了下一个代码 template<typename MyType> inline void function() { /*some code here*/; } 看起来一切都很好,但是如果我在模板中添加任何代码(即使是有错误的代码),VS不会检测到更改并告知构建成功。 例如: template<typename MyType> inline void function() { this is a plane text so,

假设我已经在头文件中编写了下一个代码

template<typename MyType> 
inline void function()
{
    /*some code here*/;
} 
看起来一切都很好,但是如果我在模板中添加任何代码(即使是有错误的代码),VS不会检测到更改并告知构建成功。 例如:

template<typename MyType> 
inline void function()
{
    this is a plane text so, compiler should give an error //line with error
    /*some code here*/;
} 

如果我在模板之外添加任何错误代码,VS会告诉我构建失败,之后它会实际查找模板内外的所有错误。强制VS检测模板内任何更改的另一种方法是重建整个项目,但在我的情况下,这需要太多时间,所以我想找到其他方法来强制VS检测代码中的更改?有人能告诉我为什么会出现这种情况,我如何克服它吗

如果未实例化模板类的适当实例,则不会编译该模板类中的代码


标准规定了这一点,各种元编程技术也利用了这一点。

如果没有实例化模板的适当实例,则不会编译模板类中的代码

标准规定了这一点,各种元编程技术也利用了这一点

template<typename MyType> 
inline void function()
{
    this is a plane text so, compiler should give an error //line with error
    /*some code here*/;
} 
 ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========