Snapchat / djinni

A tool for generating cross-language type declarations and interface bindings. Djinni's new home is in the Snapchat org.
Apache License 2.0
173 stars 50 forks source link

GlobalRef‘s copy assignment operator is implicitly deleted #158

Open 0Litost0 opened 9 months ago

0Litost0 commented 9 months ago

当我将 snap-djinni 移植到自己的项目,并尝试使用 DataRef时,有以下报错: DataRef_jni.cpp:34:25: error: object of type 'GlobalRef<jclass>' (aka 'GlobalRef<_jclass *>') cannot be assigned because its copy assignment operator is implicitly deleted classObject = jniFindClass("java/nio/ByteBuffer");

The tips are as follows: copy assignment operator is implicitly deleted because 'GlobalRef<_jclass *>' has a user-declared move constructor GlobalRef(GlobalRef && obj)

Have you encountered similar problems? I did not encounter the above problems when I tried to compile and run the demo.

li-feng-sc commented 9 months ago

What compiler are you using?

Line 34 of DataRef_jni.cpp is

            classObject = jniFindClass("java/nio/ByteBuffer");

which is indeed a call to the assignment but it should be a call to the move assignment because on the right hand is a function calljniFindClass(), so it should be an r-value.

li-feng-sc commented 9 months ago

the GlobalRef class has a user defined move assignment operator

     GlobalRef& operator=(GlobalRef&& other) noexcept {

So I don't see why this would fail to compile.