草庐IT

first-class-functions

全部标签

java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext cannot access class

Task:app:kaptGenerateStubsDebugKotlinFAILEDe:java.lang.IllegalAccessError:classorg.jetbrains.kotlin.kapt3.base.KaptContext(inunnamedmodule@0x4d1ecff7)cannotaccessclasscom.sun.tools.javac.util.Context(inmodulejdk.compiler)becausemodulejdk.compilerdoesnotexportcom.sun.tools.javac.utiltounnamedmodule@0

c++ - Visual Studio 2015 (C++) : Stop compile on first build error (not first project)

VisualStudio2015检测到编译错误时如何停止编译?我的意思是第一次构建错误(可能是第一个.cpp),而不是第一个项目,因为它需要太多时间。(我只有1个项目。)名为"StopOnFirstBuildError"的扩展不是答案,因为它停止在有错误的第一个项目。问题(更详细)当我按下F5或Ctrl+Shift+B时,编译器会编译所有(或部分)文件。在我的例子中,它可以只用5秒检测到一些错误,所以我希望它现在停止编译。但是,VS2015变得无响应。对Ctrl+Break也有很强的抵抗力。我大约需要30秒才能导航到错误位置。如何在出现第一个编译错误时自动停止编译过程?历史有anold

c++ - 处理比较 : empty classes vs. 未定义类与 void*

微软的GDI+定义了许多空类,在内部被视为句柄。例如,(sourceGdiPlusGpStubs.h)//Approach1classGpGraphics{};classGpBrush{};classGpTexture:publicGpBrush{};classGpSolidFill:publicGpBrush{};classGpLineGradient:publicGpBrush{};classGpPathGradient:publicGpBrush{};classGpHatch:publicGpBrush{};classGpPen{};classGpCustomLineCap{};

c++ - 为什么 std::tr1::function 与 Objective-C block 一起工作?

当我发现下面的代码确实有效时,我感到非常惊讶:std::vectorlist/*=...*/;std::tr1::functionfunc=^(inti){returni+1;};std::for_each(list.begin(),list.end(),func);似乎std::tr1::function能够从Objective-Cblock构造,但我不太确定是如何实现的,因为(上次我检查过),它的实现没有'专门处理block。它是否以某种方式隐式吸出底层函数指针?另外,这种行为是否未定义并且可能会改变? 最佳答案 更新:我错了,

c++ - xvalues : differences between non class types and class types

考虑下面的最小示例:#includestructS{};intmain(){Ss;std::move(s)=S{};}它编译没有错误。如果我改为使用非类类型,则会收到错误。例如,以下代码无法编译:#includeintmain(){inti;std::move(i)=42;}枚举、作用域枚举等也是如此。错误(来自GCC)是:usingxvalue(rvaluereference)aslvalue这背后的原理是什么?我想这是对的,但我想了解我可以对除非类之外的所有类型执行此操作的原因是什么。 最佳答案 C++允许对类对象右值进行赋值,

c++ - std::function 在 VS2012 中无法编译

我正在尝试编译以下取自here的代码但我收到编译错误。有没有人知道可能出了什么问题?代码#include#includestructFoo{Foo(intnum):num_(num){}voidprint_add(inti)const{std::coutf_add_display=&Foo::print_add;Foofoo(314159);f_add_display(foo,1);}编译错误:Error1errorC2664:'std::_Func_class::_Set':cannotconvertparameter1from'_Myimpl*'to'std::_Func_base

c++ - 使用 std::function 时如何解决此 <unresolved overloaded function type> 错误?

在以下(有效的)代码示例中,模板化的register_enum()函数用于迭代枚举并调用用户提供的回调以将枚举值转换为C字符串。所有枚举都在一个类中定义,枚举到字符串的转换是使用静态to_cstring(enum)函数完成的。当一个类(如下面的着色器类)有多个枚举和相应的重载to_cstring(enum)函数时,编译器无法决定将哪个是正确的to_cstring()函数传递给register_enum()。我认为代码比我能解释得更好...#include#include//ActualcodeusesLua,butforsimplification//I'llhideitinthise

c++ - 多重继承 : 2Classes1Method

我刚刚试过这段代码:structFaceOfPast{virtualvoidSmile()=0;};structFaceOfFuture{virtualvoidSmile()=0;};structJanus:publicFaceOfPast,publicFaceOfFuture{virtualvoidSmile(){printf(":)");}};...voidmain(){Janus*j=newJanus();FaceOfFuture*future=j;FaceOfPast*past=j;future->Smile();past->Smile();deletej;}它按预期工作(输出

C++ 将 std::function 对象传递给可变参数模板

我想将一个可调用对象(std::function对象)传递给一个类Foo.可调用对象引用另一个具有任意参数的类的成员方法,因此Foo必须是可变参数模板。考虑这段代码:structBar{voidMemberFunction(intx){}};templateclassFoo{public:Foo(std::functionf){}};intmain(){Foom1(&Bar::MemberFunction);return0;}这编译得很好。现在我想写一个工厂函数MakeFoo()返回unique_ptr到Foo对象:templatestd::unique_ptr>MakeFoo(std

c++ - 经典C++(C with Classes)的Call/Return特性,现代语言有哪些?

在TheDesignandEvolutionofC++的第57页上,Dr.Stroustrup谈到了一个功能,该功能最初是CwithClasses的一部分,但它不是现代C++(标准C++)的一部分。该功能称为call/return。这是一个例子:classmyclass{call(){/*dosomethingbeforeeachcalltoafunction.*/}return(){/*dosomethingelseaftereachcalltoafunction.*/}...};我觉得这个功能非常有趣。有没有现代语言有这个特殊的功能? 最佳答案