libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.49k stars 924 forks source link

error C2280: 'cpr::File &cpr::File::operator =(const cpr::File &)': attempting to reference a deleted function #897

Closed Adela0814 closed 1 year ago

Adela0814 commented 1 year ago

Description

install-x64-windows-dbg-out.log

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\vector(1485): error C2280: 'cpr::File &cpr::File::operator =(const cpr::File &)': attempting to reference a deleted function
E:\vcpkg\installed\x64-windows\include\cpr\file.h(21): note: compiler has generated 'cpr::File::operator =' here
E:\vcpkg\installed\x64-windows\include\cpr\file.h(21): note: 'cpr::File &cpr::File::operator =(const cpr::File &)': function was implicitly deleted because a data member 'cpr::File::overrided_filename' has either no appropriate copy assignment operator or overload resolution was ambiguous
E:\vcpkg\installed\x64-windows\include\cpr\file.h(16): note: see declaration of 'cpr::File::overrided_filename'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\vector(1561): note: see reference to function template instantiation 'void std::vector<cpr::File,std::allocator<cpr::File>>::_Assign_counted_range<cpr::File*>(_Iter,const unsigned __int64)' being compiled
        with
        [
            _Iter=cpr::File *
        ]

Example/How to Reproduce

  1. Update cpr to latest version in vcpkg. see https://github.com/microsoft/vcpkg/pull/30747.
  2. Set CMAKE_CXX_STANDARD=17 for sleepy-discord (sleep-discord depends on cpr)
  3. See error

Possible Fix

No response

Where did you get it from?

vcpkg

Additional Context/Your Environment

COM8 commented 1 year ago

@Adela0814 thanks for reporting! This got caused by: https://github.com/libcpr/cpr/pull/890

I will look into this next weekend.

Adela0814 commented 1 year ago

@COM8 Thank you for your help. I pulled your latest changes and now there are new errors: error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'cpr::Part'

COM8 commented 1 year ago

Ah, I added explicit for the Files constructor. I removed it again to not brick existing code here. Thanks for reporting!

Adela0814 commented 1 year ago

All my problems have been resolved. Thank you very much!