草庐IT

long_ptr

全部标签

java - 当 l(long) -= f(float) 时发生了什么?

这个问题在这里已经有了答案:Floatingpointarithmeticnotproducingexactresults[duplicate](7个答案)WhydoesJavaimplicitly(withoutcast)converta`long`toa`float`?(4个答案)关闭6年前。publicclassSimplePrint{publicstaticvoidmain(String[]args){longi=System.currentTimeMillis();System.out.println(i);floath=0.0f;i-=h;System.out.printl

java - 在 32 位和 64 位机器上都是 long 总是 64 位

我想知道long在x86和x64中是否都是64位? 最佳答案 是的。Javalong在任何JVM上都是64位的,无一异常(exception)。所有Java基本类型都是完全可移植的,并且在所有实现中都具有固定大小。 关于java-在32位和64位机器上都是long总是64位,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8759857/

java - Long、Integer 和 Short 比较方法的不同实现?

为什么Java库中Long、Integer和Short的静态方法compare的实现不同?对于长:publicstaticintcompare(longx,longy){return(x对于整数:publicstaticintcompare(intx,inty){return(x对于短:publicstaticintcompare(shortx,shorty){returnx-y;} 最佳答案 如果你尝试:System.out.println(Long.MIN_VALUE-Long.MAX_VALUE);或System.out.pr

java - Hibernate 参数值 [568903] 与预期类型不匹配 [java.lang.Long]

我正在使用Hibernate4,我在JSF页面中有一个过滤器来获取搜索结果。在执行搜索期间,我收到以下异常java.lang.IllegalArgumentException:Parametervalue[568903]didnotmatchexpectedtype[java.lang.Long]atorg.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:370)atorg.hibernate.ejb.AbstractQueryImpl.registerParameterBi

c++ - std::shared_ptr 什么时候释放它的对象?

我在使用GCC4.8.4的Ubuntu14.04上,我的代码类似于以下内容:std::shared_ptrmy_shared_object=setelsewhere...MyFunction(*my_shared_object);MyFunction的签名如下所示:voidMyFunction(constMyClass&my_object)可以找到完整的代码here但是,我发现my_object实际上超出了MyFunction上下文中的范围。我的想法是my_shared_object只有在超出范围后才会释放其内容,这意味着在MyFunction返回之后。我不确定我是否误解了std::s

c++ - 将派生类的 unique_ptr 添加到基类 unique_ptr 的 vector 中

关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭6年前。Improvethisquestion我有一个std::unique_ptr我想添加到std::vector>.std::unique_ptrderivedObject;std::vector>vec;vec.push_back(derivedObject)//Invalidarguments

c++ - 这是对 unique_ptr 的误用吗?

我正在转向智能指针,并努力确保正确使用它们。有很多问题涵盖了何时使用每个问题,但我找不到专门关于getter的问题。我有一个拥有指针的类,我希望其他类能够访问该指针(逐步重构遗留代码)。我想给这个类一个unique_ptr因为它只会拥有那个对象,但它们不能被复制。我应该返回对unique_ptr的引用,还是只使用shared_ptr?classB{public:doAction(){};};classA{private:std::unqiue_ptrpointer;public:std::unique_ptr&GetPointer(){returnpointer;}};a.GetPoi

c++ - 制作 shared_ptr 的拷贝时会发生什么?

我想了解当将shared_ptr分配给另一个时,shared_ptr中托管对象的引用计数会受到怎样的影响。我在C++primer,5thedition中看到以下声明:Forexample,thecounterassociatedwithashared_ptrisincrementedwhen...weuseitastheright-handoperandofanassignment...Thecounterisdecrementedwhenweassignanewvaluetotheshared_ptr...举个例子:autop=make_shared(42);//objecttowh

c++ - 使用累加对包含 long long int 的 vector 求和

#include#include#include#includeusingnamespacestd;intmain(){intN;cin>>N;longlongintx,sum=0;std::vectorv;for(inti=0;i>x;v.push_back(x);}/*vector::iteratoritr;itr=v.begin();for(itr=v.begin();itr我的程序使用accumulate返回抽象值,但如果我使用for循环,答案就来了。 最佳答案 std::accumulate有一个小陷阱,即您传递的初始值。

c++ - 如何深度复制 unique_ptr 的 vector

我有一个带有数据成员的容器类。std::vector>Functions;我想在我的复制构造函数中做一个深拷贝,我怎样才能做一个std::unique_ptr的深拷贝。 最佳答案 std::vector>copiedFunctions;std::for_each(Functions.begin(),Functions.end(),[&](std::unique_ptrf){copiedFunctions.push_back(std::make_unique(*f));}));这意味着Sum_Function当然有一个复制构造函数。