#cpr cannot call constructor

1 messages · Page 1 of 1 (latest)

solemn prism
#

Any idea why i get this error?

frozen dustBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

solemn prism
#
'cpr::Session &cpr::Session::operator =(cpr::Session &&) noexcept': attempting to reference a deleted function
#
    session = cpr::Session();
#
class LCU
{
public:
    static inline cpr::Session session;
}

this is how the class looks like

lime sandal
#

move assignment operator has been explicitely declared as deleted

solemn prism
#

uh?

#
class Session : public std::enable_shared_from_this<Session> {
  public:
    Session();
    Session(const Session& other) = delete;
    Session(Session&& old) = delete;

    ~Session() = default;

    Session& operator=(Session&& old) noexcept = delete;
    Session& operator=(const Session& other) = delete;```
#

thats their code

lime sandal
#

so basically

solemn prism
#

you are talking about the second last line, no?

lime sandal
#

you declared session as a cpr::Session object and its default constructor gets called automatically, and then later you try to assign another value to session with the line session = cpr::Session();, which uses the = operator

solemn prism
#

and that got "disabled" by setting it to delete?

tardy badge
#

Yep

solemn prism
#

meaning i cannot reinstanciate the object hence its being instanciated if the constructor gets called which happens on the static inline cpr::Session session?

lime sandal
#

yeah, I'm wondering, where do you define the static variable?

#

you only showed the declaration

solemn prism
#

well it was about to happen here

#
bool LCU::InitClientInfo(const ClientInfo& info)
{
session = cpr::Session();
    session.SetVerifySsl(false);

    session.SetHeader(Utils::StringToHeader(league.header));

    return true;
}
lime sandal
#

but isn't there any cpr::Session LCU::session = ... in your code?

#

oh nvm

#

it's inline already

solemn prism
#

nop

lime sandal
#

then, it's already default constructed

solemn prism
#

so there i no need to assign it, because i cant

lime sandal
#

yeah you can't and it already has been initialized anyway

solemn prism
#

that makes sense

#

thank you!!

frozen dustBOT
#

@solemn prism Has your question been resolved? If so, type !solved :)

solemn prism
#

!solved