草庐IT

optional_argument

全部标签

c++ - 为什么在 std::optional 的某些实现中存在虚拟 union 成员?

libstdc++(GNU)和libc++(LLVM)都使用union实现std::optional值存储,并且它们都包含一个虚拟成员。GNU实现:using_Stored_type=remove_const_t;struct_Empty_byte{};union{_Empty_byte_M_empty;_Stored_type_M_payload;};LLVM实现:union{char__null_state_;value_type__val_;};我的问题是:为什么我们需要这些_M_empty/__null_state_成员?单人union有什么问题吗?

ruby - 我怎样才能使用 Gemfile 的 :path argument to reference local gems in development with a value that is OS agnostic?

我正在编写一个Gemfile来帮助开发我的团队正在创建的一些gem。我知道Gemfile允许使用:path参数来引用包含.gemspec文件的本地目录:gem"my_gem",:path=>"../Ruby_Libs/my_gem"但是,我的团队成员在编写代码时使用不同的操作系统(OSX、WinXP、Win7)。所以我的问题是如何使用Gemfile的:path参数来引用开发中的本地gem,其值与操作系统无关? 最佳答案 使用File.join('..','Ruby_Libs','my_gem'')而不是"../Ruby_Libs/m

c++ - Visual Studio 错误 D8016 : '/ZI' and '/Gy' command-line options are incompatible

我正在处理的项目有问题。尽管代码是正确的,但我无法构建它,因为出现以下错误ErrorD8016'/ZI'and'/Gy-'command-lineoptionsareincompatibleLoadReportC:\LoadReport\LoadReport\cl我的VisualStudio版本是2015年。任何想法都将不胜感激。 最佳答案 在配置属性中(Project➔Properties),“/ZI”在C/C++➔General➔DebugInformationFormat“/Gy”在C/C++➔CodeGeneration➔E

c++ - Visual Studio 错误 D8016 : '/ZI' and '/Gy' command-line options are incompatible

我正在处理的项目有问题。尽管代码是正确的,但我无法构建它,因为出现以下错误ErrorD8016'/ZI'and'/Gy-'command-lineoptionsareincompatibleLoadReportC:\LoadReport\LoadReport\cl我的VisualStudio版本是2015年。任何想法都将不胜感激。 最佳答案 在配置属性中(Project➔Properties),“/ZI”在C/C++➔General➔DebugInformationFormat“/Gy”在C/C++➔CodeGeneration➔E

c++ - 从 v8::Arguments 转换为 C++ 类型

我正在尝试用C++创建Node.js模块,但我对v8::Arguments类感到困惑。假设我有一个用于发送电子邮件的Javascript类,它有一个带有此签名的方法:Mailer::sendEmail(Arrayrecipients,Stringsender,Stringmessage);会这样调用:mailer.sendEmail(["joe@gmail.com","sally@gmail.com"],"fred@gmail.com","Hithere");现在在C++领域,我有一个带有这个签名的类函数:SendEmail(constv8::Arguments&args)在Javas

c++ - 从 v8::Arguments 转换为 C++ 类型

我正在尝试用C++创建Node.js模块,但我对v8::Arguments类感到困惑。假设我有一个用于发送电子邮件的Javascript类,它有一个带有此签名的方法:Mailer::sendEmail(Arrayrecipients,Stringsender,Stringmessage);会这样调用:mailer.sendEmail(["joe@gmail.com","sally@gmail.com"],"fred@gmail.com","Hithere");现在在C++领域,我有一个带有这个签名的类函数:SendEmail(constv8::Arguments&args)在Javas

c++ - GCC 问题 : using a member of a base class that depends on a template argument

以下代码不能用gcc编译,但可以用VisualStudio编译:templateclassA{public:Tfoo;};templateclassB:publicA{public:voidbar(){cout我得到错误:test.cpp:Inmemberfunction‘voidB::bar()’:test.cpp:11:error:‘foo’wasnotdeclaredinthisscope但它应该是!如果我将bar更改为voidbar(){coutfoo然后它确实编译,但我不认为我必须这样做。GCC在此处遵循的C++官方规范中是否有某些内容,还是只是一个怪癖?

c++ - GCC 问题 : using a member of a base class that depends on a template argument

以下代码不能用gcc编译,但可以用VisualStudio编译:templateclassA{public:Tfoo;};templateclassB:publicA{public:voidbar(){cout我得到错误:test.cpp:Inmemberfunction‘voidB::bar()’:test.cpp:11:error:‘foo’wasnotdeclaredinthisscope但它应该是!如果我将bar更改为voidbar(){coutfoo然后它确实编译,但我不认为我必须这样做。GCC在此处遵循的C++官方规范中是否有某些内容,还是只是一个怪癖?

c++ - 关于c++转换: no known conversion for argument 1 from ‘[some_class]' to ‘[some_class]&’

我正在使用C++,但出现了一个我不知道确切原因的错误。我找到了解决方案,但仍然想知道为什么。classBase{public:voidsomething(Base&b){}};intmain(){Baseb;b.something(Base());return0;}当我编译代码时,出现以下错误:abc.cpp:12:20:error:nomatchingfunctionforcallto‘Base::something(Base)’abc.cpp:12:20:note:candidateis:abc.cpp:6:7:note:voidBase::something(Base&)abc.

c++ - 关于c++转换: no known conversion for argument 1 from ‘[some_class]' to ‘[some_class]&’

我正在使用C++,但出现了一个我不知道确切原因的错误。我找到了解决方案,但仍然想知道为什么。classBase{public:voidsomething(Base&b){}};intmain(){Baseb;b.something(Base());return0;}当我编译代码时,出现以下错误:abc.cpp:12:20:error:nomatchingfunctionforcallto‘Base::something(Base)’abc.cpp:12:20:note:candidateis:abc.cpp:6:7:note:voidBase::something(Base&)abc.