草庐IT

ambiguous

全部标签

java - Joda Time : Convert local to UTC ambiguity

我正在尝试使用JodaTime将本地日期转换为UTC.我使用的代码如下所示,效果很好。DatelocalDate=newDate();System.out.println("LocalDate:"+localDate);DateTimeZonetz=DateTimeZone.getDefault();DateutcDate=newDate(tz.convertLocalToUTC(localDate.getTime(),false));System.out.println("UTCDate:"+utcDate);Output:LocalDate:WedMay2911:54:46EEST

java - JDK-9 不允许我使用字符串 : "java.lang.String is ambiguous"?

一周前,我的每个项目都正常工作,但是当我将Eclipse更新到Oxygen版本并安装JDK-9时,事情就变得奇怪了。当我尝试使用字符串时,一段时间后(更像是每次我保存项目时),编译器会针对我项目中的每个字符串向我抛出一个错误。字符串类型被识别为有歧义的类"Thetypejava.lang.Stringisambiguous"所以我尝试导入java.lang.String看看它是否修复了错误:导入后"Thepackagejava.langisaccessiblefrommorethanonemodule:java.base,java.base"惊喜!?它不会:(我尝试在Google和SO

c++ - 有没有办法在用户定义的转换中指定优先级?

免责声明:我知道通常不鼓励使用用户定义的隐式转换。但是,在我们的项目中,我们需要各种模板类的这些转换才能相互很好地协同工作。我需要定义用户定义转换的优先级,例如:structX{}structY{}structZ{operatorX(){...}operatorY(){...}}voidfoo(Xx){...}voidfoo(Yy){...}//somewhereinsometemplateclientcode...{Zz=...;...foo(z);//WILLNOTCOMPILE}这不会编译,因为从Z到X或Y的转换是不明确的。有没有办法解决这种歧义。即,我能否以某种方式告诉编译器:

c++ - 这个函数调用在 C++ 中是如何模糊的?

考虑以下程序:(请在此处查看现场演示http://ideone.com/7VHdoU)#includevoidfun(int*)=delete;voidfun(double)=delete;voidfun(char)=delete;voidfun(unsigned)=delete;voidfun(float)=delete;voidfun(longint);intmain(){fun(3);}voidfun(longinta){std::cout编译器给出以下错误:error:callofoverloaded'fun(int)'isambiguousfun(3);^但我不明白为什么以及

c++ - 转发声明使用 enable_if : ambiguous call 的函数

我在声明一个使用boost::enable_if的函数时遇到了一些麻烦:下面的一段代码给我一个编译器错误://Declarationtemplatevoidfoo(Tt);//Definitiontemplatetypenameboost::enable_if>::typefoo(Tt){}intmain(){foo(12);return0;}编译时,出现“对foo的模糊调用”错误。根据enable_if的定义,'type'typedef在条件为真时对应于void,据我所知,的两个签名foo匹配。为什么编译器认为它们不同,是否有正确的方法来转发声明foo(最好不要重复enable_if

C++ 对重载函数的奇怪模棱两可的调用

这个问题在这里已经有了答案:Whatis"Argument-DependentLookup"(akaADL,or"KoenigLookup")?(4个答案)关闭9年前。首先,这个问题纯属理论性质。我不是在寻找解决方案(我已经知道了),我只是在寻找解释。以下代码无法编译:structfoo{};voida(foo){}namespacefoobar{voida(foo){}voidb(foof){a(f);}}intmain(){return1;}MSVC++:1>c:\projects\codetests\main.cpp(7):errorC2668:'foobar::a':ambig

c++ - 可变参数模板中的模糊运算符[]

我正在尝试编译这个例子,其中一个可变类模板继承自可变数量的基类,每个基类实现不同的operator[]:#includetemplatestructField{typenameT::value_typestorage;typenameT::value_type&operator[](constT&c){returnstorage;}};templatestructctmap:publicField...{};intmain(){structage{typedefintvalue_type;};structlast_name{typedefstd::stringvalue_type;};

c++ - C++中的继承, "...is an ambiguous base of ..."错误

如“TheC++ProgrammingLanguage3.Edition-BjarneStroustrup”中所写。我们可以使用范围解决方案来防止歧义错误。下面的基本程序,当我在类混合中使用3层范围时,会发生错误。但是当我使用2层时没问题。怎么了?还是像设计问题?错误是;deneme.cpp:Inconstructor‘mix::mix(std::__cxx11::string,int)’:deneme.cpp:45:22:error:‘plane’isanambiguousbaseof‘mix’pervaneli::plane::engine=b;我不想制作钻石模型。我对两个基础(平

c++ - QObject 继承 Ambiguous Base

我有一个简单的类,它在我的程序获得和失去焦点时停止和启动计时器,但它给出了错误,即QObject在每个信号槽连接上都是MyApp的模糊基础。相关代码如下:classMyApp:publicQApplication,publicQObject{Q_OBJECT...}这是我的(凌乱的)Main.cpp:#include#include"qmlapplicationviewer.h"#include#include#include#include#include"timecontrol.h"#include"scorecontrol.h"#include"Retry.h"#include#

c++ - 不明确的类继承

#include#includeusingnamespacestd;classTcirculo{floatradio;floatdiametro;floatarea;public:voidcarea(floatr){radio=r;area=(M_PI*((r*r)));}floatcdiam(floatr){diametro=2*r;returndiametro;}floatgetr(){returnradio;}floatgetd(){returndiametro;}floatgeta(){returnarea;}};classTrectangulo:publicTcirculo{