草庐IT

syntax-checking

全部标签

c++ - Visual Studio 2015 "non-standard syntax; use ' &' to create a pointer to member"

我正在尝试用C++实现自己的链表,但终究无法弄清楚为什么会出现此错误。我知道有一个STL实现,但出于某种原因,我正在尝试自己的实现。这是代码:#includetemplateclassListElement{public:ListElement(constT&value):next(NULL),data(value){}~ListElement(){}ListElement*getNext(){returnnext;}constT&value()const{returnvalue;}voidsetNext(ListElement*elem){next=elem;}voidsetValu

c++ - BOOST_CHECK_CLOSE 即使两个值低于阈值也会失败

我正在使用boost执行单元测试。当我使用BOOST_CHECK_CLOSE时,我收到此失败消息:difference{inf%}{-6.9388939e-18}and(0.0){0}exceeds1.0000000000000001e-05%这对我来说听起来很奇怪,因为-6.9388939e-18和0.0之间的差异低于1.0000000000000001e-05%。此外,我不明白为什么它说差异是无限的。知道这种行为背后的原因吗? 最佳答案 BOOST_CHECK_CLOSE使用Knuth的公差谓词来比较float,即abs(x-y

c++ - 除以零预防 : Checking the divisor's expression doesn't result in zero vs. 检查除数不为零?

由于减法中的浮点错误,在以下情况下是否可以被零除?floatx,y,z;...if(y!=1.0)z=x/(y-1.0);换句话说,下面是不是更安全一些?floatdivisor=y-1.0;if(divisor!=0.0)z=x/divisor; 最佳答案 假设IEEE-754float,它们是等价的。FP算法的一个基本定理是,对于有限的x和y,x-y==0当且仅当x==y,假设逐渐下溢。如果次正规结果被刷新为零(而不是逐渐下溢),则只有当结果x-y是正规的时,这个定理才成立。因为1.0的缩放比例很好,所以y-1.0永远不会低于正

c++ - BOOST_CHECK_EQUAL 与 pair<int, int> 和自定义运算符 <<

当尝试执行BOOST_CHECK_EQUAL(pair,pair)时,gcc没有找到pair的流运算符,尽管声明了它。有趣的是std::out找到了运算符。ostream&operator&p){s';returns;}BOOST_AUTO_TEST_CASE(works){pairexpected(5,5);pairactual(5,5);std::coutexpected(5,5);pairactual(5,5);BOOST_CHECK_EQUAL(actual,expected);}这不会编译错误:...instantiatedfromhere../boost-atp/relea

c++ - 类型特征 : Check if reference member variable is static or not

我想检查一个类的成员变量是否是静态的。使用std::is_member_pointer适用于除引用成员之外的所有类型。#includestructA{intfoo;};structB:A{};structC{staticintfoo;};structD:C{};structE{int&foo;};structF{staticint&foo;};static_assert(std::is_member_pointer::value,"No");static_assert(std::is_member_pointer::value,"No");static_assert(!std::is_

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++ - std::error_code,my_error::check_block == my_error::validate && my_error::accept_block == my_error::validate

我正在使用std::error_code并定义和注册了一堆错误(使用枚举类)。我有一个非常通用的错误,现在称为my_error::validate,但我想在我的库中提供更具体的版本。通常人们会想要使用:if(ec==bc::error::validate)//...但是有时他们可能希望看到与该std::error_code关联的特定错误或打印错误消息。//ec.message()says"check_block()failedtodoXYZ"assert(ec==bc::error::check_block);我希望能够启用如下功能:if(ec==bc::error::validate

android - 房间 (AAC) : [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

FollowingDao没有在我的Android应用中构建:@DaointerfaceGroupDao{@Insertfuninsert(group:Group)@Query("SELECT*FROMgroup")funloadAll():LiveData>}当我在AndroidStudio3中构建项目时,我在gradle构建步骤中收到以下错误::app:kaptDebugKotline:C:\workspaces\SystemicConsensusKotlin\app\build\tmp\kapt3\stubs\debug\de\maxdobler\systemicconsensus

android - 房间 (AAC) : [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

FollowingDao没有在我的Android应用中构建:@DaointerfaceGroupDao{@Insertfuninsert(group:Group)@Query("SELECT*FROMgroup")funloadAll():LiveData>}当我在AndroidStudio3中构建项目时,我在gradle构建步骤中收到以下错误::app:kaptDebugKotline:C:\workspaces\SystemicConsensusKotlin\app\build\tmp\kapt3\stubs\debug\de\maxdobler\systemicconsensus

c++ - 错误 C2146 : syntax error : missing ';' before identifier

我无法摆脱这些错误...我检查的每个地方都有分号...代码很简单:该错误将我带到article.h中的定义“字符串名称”...主要.cpp#include#include#include#includeusingnamespacestd;#include"article.h"intmain(){stringsi;chararticle[128];vectorarticles;ifstreamfile;file.open("input.txt",ifstream::in);while(!file.eof()){file.getline(article,128);articles.push