草庐IT

extend-anonymous-types-using

全部标签

c++ - LNK1112 : module machine type 'x64' conflicts with target machine type 'X86' : Qt creator

我有一个在linux上运行的应用程序,我正试图将其导入到windows上。我已经设置了所有库并对.pro文件进行了更改。现在,当我尝试构建项目时出现此错误:error:LNK1112:modulemachinetype'x64'conflictswithtargetmachinetype'X86'我不确定是什么导致了这个问题。我正在使用32位Qtcreator。我知道有几个链接讨论了更改项目属性,但所有这些都与在VisualStudio中更改它们有关。我正在使用Qtcreator并通过QtUI运行项目。所以我不确定如果必须解决这个问题,必须通过Qt对项目属性进行哪些更改。

c++ - 为什么编译器说 : 'enable_if' cannot be used to disable this declaration

templateusingEnable_if=typenamestd::enable_if::type;classDegree;templateconstexprinlineboolIs_Degree(){returnstd::is_base_of::value;}classDegree{public:std::size_tinDeg=0;};templateclassVertex:publicSatellite{public:explicitVertex(intnum):n(num){}private:std::size_tn;};templateclassEdge{public:/

C++ 调试窗口显示“<incomplete type> for string variable

据我所知,我正在以一种相当正常的方式初始化一个字符串,当我调试时,我的IDE(CLion)中的变量窗口将其值显示为.我有一些简单的代码导致字符串变量Bob出现问题.#includeintmain(){std::stringBob="thisdoesn'tshowupinthevariableswindow";std::cout我不知道它有什么影响,但我会包含CMakeLists文件,它似乎是我可以使用的最简单的文件。cmake_minimum_required(VERSION3.8)project(testing123)set(CMAKE_CXX_FLAGS"${CMAKE_CXX_F

C++ 命名空间 - "using"或明确说明?

这个问题在这里已经有了答案:关闭12年前。PossibleDuplicates:Whyis‘usingnamespacestd;’consideredabadpracticeinC++?UsingstdNamespace这只是一个偏好问题吗?或者是否有更喜欢的正当理由usingnamespacestd;#includemyStringstring;或#includemyStringstd::string;我想每次都显式声明命名空间,同时拖动输入,避免了任何可能的名称冲突(或者编译器会警告歧义吗?)问题:是否有令人信服的论据?

c++ - '#include' 和 'using' 语句是否应该在头文件和实现文件 (C++) 中重复?

我是C++的新手,但我的理解是#include语句基本上只是将#included文件的内容转储到该语句的位置。这意味着如果我的头文件中有许多'#include'和'using'语句,我的实现文件可以只#include头文件,如果我不重复其他语句,编译器就不会介意.但是人呢?我主要担心的是,如果我不重复“#include”、“using”和“typedef”(现在我想到了)语句,它会从它所在的文件中获取该信息使用,这可能会导致混淆。目前我只是在处理小型项目,它不会真正造成任何问题,但我可以想象,在有更多人参与的大型项目中,它可能会成为一个重大问题。例子如下:更新:我的“Unit”函数原型

c++ - 迭代器模式 - 错误 C2679 : binary '<<' : no operator found which takes a right-hand operand of type 'std::string'

这个问题在这里已经有了答案:errorC2679:binary'(1个回答)关闭5年前。我正在尝试使用迭代器模式进行迭代和打印,但出现错误这里是错误:errorC2679:binary'couldbe'std::basic_ostream&std::operator>(std::basic_ostream&,constchar*)'这是错误的来源std::coutgetName();#ifndef_ROBOT1_#define_ROBOT1_namespaceguitars{namespaceComposite{namespaceInventoryParts{usingnamespac

c++ - 警告 C4251 : needs to have dll-interface to be used by clients of class

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:std::vectorneedstohavedll-interfacetobeusedbyclientsofclass'Xwarning这是我在该组中的第一篇文章。我正在创建一个DLL并在应用程序的主文件中调用它。代码编译正常,但出现以下错误:warningC4251:'PNCBaseClass::m_vAvailChannelsFromRx':class'std::vector'needstohavedll-interfacetobeusedbyclientsofclass'PNCBaseClass'3>w

如何正确地从函数(type_traits)提供向量

我如何返回std::vector由此operator+()?#include#include#include#include#includetemplatestructis_std_vector:std::false_type{};templatestructis_std_vector>:std::true_type{};templatestd::enable_if_t>::value>operator+(T&&vec1,T&&vec2){for(inti=0;i(vec2.at(i)));returnvec1;}intmain(){std::vectorvec1{1,2,3,4,5};std

c++ - 如何在 C++11 中将容器 std::array<type, size> 用于多维数组?

例如,包含三个整数的一维数组可以定义为std::arraymyarray或myarray[3].有没有像std::array这样的容器对于像myarray[3][3]这样的多维数组? 最佳答案 一个关键部分是确保{}初始化工作类似于std::array,并尽可能合理地让自己保持pod状。与std::array的兼容性也很重要,什么比std::array更兼容??所以我的解决方案从std::array中生成多维数组小号:templatestructmulti_array_helper{usingtype=T;};templateusi

c++ - 从 back_insert_iterator 中提取容器的 value_type 的特征类

std::back_insert_iterator的value_type等于void,但它还有一个protected成员container包含指向底层Container的指针。我正在尝试编写一个traits类来提取容器的value_type,如下所示:#include#include#includetemplatestructoutit_vt:OutputIt{usingself_type=outit_vt;usingvalue_type=typenamestd::remove_pointer_t().container)>::value_type;};intmain(){std::v