openfheorg / openfhe-development

This is the development repository for the OpenFHE library. The current (stable) version is v1.2.0 (released on June 25, 2024).
BSD 2-Clause "Simplified" License
655 stars 167 forks source link

Delete const from return type in "virtual const std::vector<double> GetRealPackedValue() const" signature in the "PlaintextImpl" class. #777

Closed HovsepPapoyan closed 1 month ago

HovsepPapoyan commented 1 month ago

Constness in the return type breaks user-side move semantics (including use-cases like openfhe-rs). Please consider removing the constness.

HovsepPapoyan commented 1 month ago

see simplified example of the issue:

https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:34,endLineNumber:21,positionColumn:34,positionLineNumber:21,selectionStartColumn:34,selectionStartLineNumber:21,startColumn:34,startLineNumber:21),source:'%23include+%3Cvector%3E%0A%23include+%3Cmemory%3E%0A%23include+%3Ciostream%3E%0A%0Aclass+A%0A%7B%0Apublic:%0A++++A()+%3D+default%3B%0A++++A(const+A%26)+%7B+std::cout+%3C%3C+%22copy+constr%22+%3C%3C+std::endl%3B+%7D%0A++++A(A%26%26)+%7B+std::cout+%3C%3C+%22move+constr%22+%3C%3C+std::endl%3B+%7D%0A%7D%3B%0A%0Aconst+A+f()%0A%7B%0A++++A+object%3B%0A++++return+object%3B%0A%7D%0A%0Aint+main()%0A%7B%0A++++std::unique_ptr%3CA%3E+ptr+%3D+std::make_unique%3CA%3E(f())%3B%0A%7D'),l:'5',n:'1',o:'C%2B%2B+source+%231',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g141,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'',overrides:!((name:edition,value:'2021')),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+gcc+14.1+(Editor+%231)',t:'0')),k:57.73195876288659,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'rustc+1.59.0',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gcc+14.1+(Compiler+%231)',t:'0')),k:8.934707903780065,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4