草庐IT

Non-optional

全部标签

c++ - 自动配置/自动制造 : How to avoid passing the "check" option to AC_CONFIG_SUBDIRS

我正在使用Autoconf构建我的C++项目。它使用第三方代码,这些代码也是在Autoconf/Automake的帮助下构建的。所以在我的configure.ac中有以下行:AC_CONFIG_SUBDIRS([subdirectoryname])一切正常,但我还使用该功能让测试在执行makecheck时自动进行-这也是由第三方代码完成的。因为这些测试需要一段时间,所以每次我想测试自己的代码时都执行它们很烦人。那么有没有办法避免check选项被传递给子目录的Makefile呢?更新:覆盖check-recursive似乎不是一个选项,因为我的顶级Makefile.am看起来(或多或少)

c++ - MSVC : modifiers not allowed on non-memberfunction

我在linux下编写了一个信号/插槽库(Codeprojectarticlehere),同时使用Clang3.5和GCC4.9进行编译。它在两个编译器上编译时都没有警告(也在3.4版和4.8版上)。当我完成所有工作并将文章发布到网上时,没过多久我就收到投诉说它不能在MSVC上工作。(VisualStudioExpress2013?对不起,我对版本控制系统不熟悉。)我把它安装在虚拟机中自己看了一下,发现它不会编译以下内容:templatestructRemoveCV;templatestructRemoveCV{usingType=R(Args...);};templatestructR

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++ - 有什么能阻止 std::optional::value_or() 有条件地 noexcept 吗?

这是value_or()的定义来自C++17标准:templateconstexprTvalue_or(U&&v)const&;Effects:Equivalentto:returnbool(*this)?**this:static_cast(std::forward(v));Remarks:Ifis_copy_constructible_v&&is_convertible_visfalse,theprogramisill-formed.(右值重载类似)value_or的效果被描述为等同于returnbool(*this)?**this:static_cast(std::forward

c++ - 如何防止 boost::optional<T> 被错误地构造为 0?

boost::optional(1.51)提供了一种构造对象的方法,这对我的用户来说非常危险,我想避免这种情况。假设我有自己的整数类,我想传递一个可选的此类整数并将其存储在某个类中:classmyint{public:intm_a;myint(intr_a):m_a(r_a){}};structmyclass{boost::optionalcontent;myclass(constboost::optional&arg):content(arg){}};现在,用户将如何使用该类:myclass(myint(13));//correctusemyclass(boost::none);//

c++ - libc++ 与 VC++ : Can non-UTF conversions be done with wstring_convert?

C++11的std::wstring_convert效果很好*用于标准UTF-8UTF-16/UCS2/UCS4转换。但是,当我尝试使用不是来自的构面实例化wstring_convert或wbuffer_convert时,它没有按预期工作://worksasexpectedstd::wstring_convert>ucs4conv;//Now,byanalogy,Iwanttotrythis:std::wstring_convert>gbconv(newstd::codecvt_byname("zh_CN.gb18030"));Clang++错误提示“在~wstring_convert

c++ - 隐式转换 : const reference vs non-const reference vs non-reference

考虑这段代码,structA{};structB{B(constA&){}};voidf(B){cout这compilesfine,运行良好。但是,如果我将f(B)更改为f(B&),它doesn'tcompile.如果我写f(constB&),它又是compilesfine,运行良好。原因和道理是什么?总结:voidf(B);//okayvoidf(B&);//errorvoidf(constB&);//okay对于每种情况,我想听听语言规范中的原因、基本原理和引用资料。当然,函数签名本身并没有错。A隐式转换为B和constB&,但不会转换为B&,这会导致编译错误。

c++ - 'ld : unknown option: -rpath=./libs' - 在 mac os 10.7.5 上构建 openframework 插件时出现链接错误

我对编码很陌生,我正在尝试构建一个名为ofxReprojection的开放框架插件示例项目。.我去的时候:cd/Users/Macbookpro/Documents/openframeworks/addons/ofxReprojection/example-ofxKinect然后make我收到这个错误:ld:unknownoption:-rpath=./libsclang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)make[1]:***[bin/example-ofxKinect]Error1make:***

c++ - 使用 boost::optional 时避免临时

boost::optional支持像这样的in_place构造:#include#includeclassFoo{inta,b;public:Foo(intone,inttwo):a(one),b(two){}};intmain(){boost::optionalfooOpt(boost::in_place(1,3));}一旦我们有了一个初始化的fooOpt,有没有办法在不创建临时对象的情况下为它分配一个新的Foo?类似的东西:fooOpt=boost::in_place(1,3);谢谢! 最佳答案 boost::可选#includ

c++ - boost::program_options - 如何处理 INI 文件中具有相同名称的多个部分

在如下配置中;有没有办法处理各个部分。我正在寻找一种方法来以可靠的方式验证下面的各个“服务器”部分。[basic]number_of_servers=3[server]ip=10.20.30.40password=sdfslkhf[server]ip=10.20.30.41password=sdfslkhf[server]ip=10.20.30.42password=sdfslkhf[server]password=sdfslkhf[server]ip=10.20.30.42 最佳答案 当使用boost::program_optio