草庐IT

template_directory

全部标签

c++ - 什么是 diff b/w Includes in VC++ Directories options 和 Additional include directories in C++ -> General in Visual Studio

我尝试在工具->选项中的VC++目录->包含目录选项中添加包含目录,但在编译时出现错误-“找不到文件或目录”。一旦我添加到Projectproperties->Configurationproperties->C++->General->Additionalincludedirectories,我就可以成功编译。那么为什么VisualStudio有一个包含目录选项。为什么它用于?(我使用的是VisualStudio2010Beta1) 最佳答案 VisualStudio团队最近在他们的博客中解释了VS2010在包含目录方面与早期版本

c++ - 默认模板参数 : Why does the compiler complain about not specifying template argument?

我有这个代码:structA{};templatestructB{voidfoo(){}};Bb;//Error:missingtemplateargumentsbefore'b'//Error:expected';'before'b'//Moreerrorsb.foo()如果我将foo()作为具有相同模板“签名”的模板函数,编译器不会提示没有指定模板参数:structA{};structB{templatevoidfoo(){}};Bb;//OKb.foo()那么为什么我需要为带有默认参数的模板类指定参数,而不是为模板函数指定参数呢?我是否遗漏了一些微妙之处?原因肯定是因为模板参数推

c++ - 'dxerr9.h' : No such file or directory

我正在尝试编译一个程序,我从一本使用directx渲染3d对象的书中取出了一张CD。当我按编译时,出现以下错误C1083:Cannotopenincludefile:'dxerr9.h':Nosuchfileordirectory我使用的是VC++2008ExpressEdition,我运行的是Vista。我去了以下文件夹[编辑]C:\ProgramFiles(x86)\MicrosoftDirectXSDK(February2010)\Include我能够在文件夹中找到dxerr.h,路径也包含在选项窗口的VC++目录选项卡中。不知道发生了什么事。 最佳答

c++ - "Invalid template argument"错误在 Visual Studio 但不是 GCC

假设你有代码templateclassBaseType>classEST16:publicBaseType{public:EST16(doubled){}};templateclassSCEST{Ty;};typedefEST16EST16_SC;classChild:publicEST16_SC{public:Child():EST16_SC(1.0){}};classNotWorkingChild:publicEST16{public:NotWorkingChild():EST16(1.0){}};TEST(TemplateTest,TestInstantiate){Childch

c++ - Eclipse C++ 包含错误 : no such file or directory

我已经将一个C++项目加载到Eclipse(Europa)中,并且正在熟悉CDT界面。以下行有一个特别烦人的错误消息:#include"somedir/somefile.h"somedir/somefile.h:没有那个文件或目录包含文件存在于“/opt/local/project/include/somedir/somefile.h”。在Project>Properties>C/C++General>PathsandSymbols>Includes下,我已经添加了包含目录“/opt/local/project/include”。但是,这似乎并没有解决问题。有谁知道如何处理这个错误?谢

c++ - std::filesystem::directory_iterator 链接器问题 (C++17)

这个问题在这里已经有了答案:LinkerrorsusingmembersinC++17(4个答案)关闭4年前。在尝试使用C++17标准中的std::filesystem::directory_iterator时,我的C++构建出现问题。代码如下:std::vectorIO::getDirectoryList(std::filesystem::path&dirPath){std::vectorfiles;for(auto&file:std::filesystem::directory_iterator(".")){files.push_back(file.path());}returnf

c++ - 从 boost::filesystem::is_directory 捕获异常

我目前正在捕获来自boost::filesystem::is_directory的错误,并通过在异常上调用“what()”向用户显示错误。这给出了失败的原因,但错误对用户来说很奇怪。例如:boost::filesystem::is_directory:Accessisdenied我如何捕获boost错误并找出实际原因,以便显示更好的错误消息? 最佳答案 “更好的错误信息”是指类似的东西吗#include#includeintmain(){boost::filesystem::pathp("/proc/1/fd/1");try{boo

c++ - `class template Example<int>;` 语句对 C++11 意味着什么?

有人提到我"ExplicitTemplateInstantiation"在cplusplus.com,它给出了以下示例:templateclassExample{public:Example(Ttest){_data=test;}voidsetTest(Ttest){_data=T;}private:T_data;};classtemplateExample;classtemplateExample;classtemplateExample;除了在我看来是一个遗漏错误之外,试图将类型分配给成员变量--_data=T而不是我认为应该是_data=test--我不明白的是最后3行究竟声明或

c++ - 错误 : ‘list’ is not a member of ‘std’ and error: template argument 2 is invalid

我正在尝试编译我的头文件,但我遇到了我无法弄清楚的错误。我想创建一个包含3个映射的结构:-从单个单词映射到计数-从词对映射到计数-从单个单词映射到后续单词列表我的头文件中的代码:#include#include#include#include#include#include#include#includetypedefstruct{std::mapfirstCounts;std::mappairCounts;std::map>follows;//Youcanuseaniteratortoretrievethevaluesstoredinthelist.}LanguageModel;我得

c++ - 模板特化是否需要 template<> 语法?

我有一个类似这样的访客类:structVisitor{templatevoidoperator()(Tt){...}voidoperator()(boolb){...}};很明显,operator()(boolb)旨在成为上述模板函数的特化。但是,它没有template语法,我以前经常看到它,将其声明为模板特化。但它确实可以编译。这样安全吗?这是正确的吗? 最佳答案 您的代码不是模板特化,而是非模板函数。那里有一些差异。非模板化operator()将优先于模板化版本(对于精确匹配,但类型转换不会在那里发生)但您仍然可以强制调用模板化