草庐IT

has_typedef_X

全部标签

c++ - typedef 和在同一范围内使用相同名称的声明

我搜索了C++11标准(嗯,n3242草案)和互联网,但找不到准确的答案。下面的代码可以在clang3.2和g++4.7.2以及VisualStudio2010中正常编译,但我预计会出现错误。#include#includetypedefinta_t;namespacea_ns{classa_t{};}usinga_ns::a_t;intmain(){a_ta;std::cout内置:clang-std=c++11-pedantic-Wall-oaa.cpp-lstdc++g++-std=c++11-pedantic-Wall-oaa.cpp-lstdc++cl-EHsc-GRa.cp

c++ - 强枚举 typedef : clang bug or c++11 standard uncertainty?

对于这样的代码:typedefenumFooEnum:intFooEnum;enumFooEnum:int{A=1,B};clang(linux/7.0.0)报告没有错误[-c-std=c++11-pedantic],但是gcc(linux/8.2.1)不编译它:g++-c-std=c++11-pedantictest2.cpptest2.cpp:1:28:error:expected';'or'{'before'FooEnum'typedefenumFooEnum:intFooEnum;^~~~~~~test2.cpp:1:28:error:expectedclass-keybefo

c++ - 无法与 typedef 成为 friend : any particular reason?

structA{};typedefAB;structC{friendstructB;};GCC4.7.020110427告诉我error:usingtypedef-name'B'after'struct'.到目前为止,这似乎是不言自明的;毕竟,我的示例代码试图声明并加好友struct称为B,实际上不是struct-key.但是,我必须写friendstructA;如果A实际上是一个复杂的、冗长的模板元黑客,这是不可取的。我是不是遗漏了什么,或者我们实际上可以不friend通过类型别名类型?如果不是,是否有任何特殊原因或者只是语言的怪癖?Thisquestion之前提出过这个问题,但是已

c++ - 重载运算符<<(unsigned char typedef as byte)

我想重载(劫持?)ostream和basic_ostream以便它停止尝试将八位字节(无符号字符)显示为可打印字符。我一直住在cout和friend们在屏幕上放笑脸的时间太长了。我厌倦了与Actor一起工作:hex.是否可以覆盖标准行为?我已经尝试过模板和非模板覆盖。它们编译,但似乎没有被调用。 最佳答案 问题是已经有一个templatestd::basic_ostream&operator&,charT);在namespacestd.自basic_ostream也在这个命名空间中,ADL在你输出unsignedchar时选择它.添

c++ - 具有 typedef 返回值的模板化成员函数

为什么下面的代码给我一个错误(g++4.1.2)?templateclassFoo{public:typedefstd::vectorAVec;AVec*foo();};templateFoo::AVec*Foo::foo(){//erroronthislinereturnNULL;}错误是:error:expectedconstructor,destructor,ortypeconversionbefore'*'token我应该如何定义Foo::foo()以其他方式运行(具有正确的返回类型)? 最佳答案 这是一个名为“two-st

C++ 错误 : object of abstract class type is not allowed: pure virtual function has no overrider

继承有问题。我不知道我做错了什么。FigureGeometry.h#ifndefFIGUREGEOMETRY#defineFIGUREGEOMETRYstaticconstfloatPI=3.14159f;classFigureGeometry{public:virtualfloatgetArea()const=0;virtualfloatgetPerimeter()const=0;};#endifCircle.h#ifndefCIRCLE#defineCIRCLE#include"FigureGeometry.h"classCircle:publicFigureGeometry{fl

iphone - 警告 : XXXX has different visibility (default) in YYYY and (hidden) in ZZZZ

我正在尝试制作一个使用OpenCV和另一个C++库的iPhone应用程序。它似乎可以很好地编译和链接。它确实有效。只是我想摆脱这个丑陋的警告:ld:warning:std::vector>::_M_insert_aux(__gnu_cxx::__normal_iterator>>,intconst&)hasdifferentvisibility(default)in/Users/nacho4d/Documents/Projects/iOS/iAR/opencv_device/lib/libcxcore.a(cxdatastructs.o)and(hidden)in/Users/nach

c++ - 继承而不是 typedef

C++无法从typedef或typedef模板化类中创建模板。我知道如果我继承并使我的类成为模板,它就会起作用。例子://IllegaltemplatetypedefMyVectorTypevector;//Valid,butadvantageous?templateclassMyVectorType:publicvector{};这样做有利于我“伪造”typedef还是有更好的方法来做到这一点? 最佳答案 C++0x将使用using添加模板类型定义关键字。您的解决方案声明了一个新类型,而不是类型“别名”,例如你不能初始化MyVec

c++ - 如何 typedef 具有未指定大小的 std::array?

我想写一些变量,比如std::arraya;哪里array_num是constint表示数组的长度。但是它很长,我想为它创建一个别名:typedefstd::arraymy_array;是吗?如何使用my_array喜欢my_array? 最佳答案 您需要的是aliastemplate:templateusingmy_array=std::array;您不能直接制作typedef模板,参见thispost.size_t是std::array采用的第二个模板参数的类型,而不是int。既然您了解了使用,您应该会使用它。它可以做typed

java - 在 Windows 上设置 hadoop.tmp.dir 会出现错误 : URI has an authority component

我试图在我的hdfs-site.xml中指定HDFS文件的基本目录在Windows7下(我从源代码构建的Hadoop2.7.1,使用JavaSDK1.8.0_45和WindowsSDK7.1)。我不知道如何提供指定驱动器的路径。我的hdfs-site.xml看起来像这样:dfs.replication1hadoop.tmp.dirXXX我尝试了XXX的各种值,我用hdfsnamenode-format测试过,所有这些都会导致以下2个错误之一:XXX=D:/tmp/hdp:15/07/1023:38:33ERRORnamenode.NameNode:Failedtostartnameno