libmem icon indicating copy to clipboard operation
libmem copied to clipboard

Cant make empty process variable

Open thesstraight opened this issue 5 months ago • 4 comments

so i have tried doing this using libmem.hpp in c++ 20

libmem::Process process{};

but when compiling with g++ i get error

error: no matching function for call to ‘libmem::Process::Process(<brace-enclosed initializer list>)’
   24 |     libmem::Process process{};

i added Process(){}; before Process(const struct lm_process_t *process); now i can do this

new code

libmem::Process process{};

    {   
        std::optional<libmem::Process> getProcess{ libmem::FindProcess(::processName.data()) };

        if (!getProcess.has_value())
        {
            std::cerr << "process not found\n";

            return 1;
        }

        process = getProcess.value();
    }

and saves me from doing this

previous code


    std::optional<libmem::Process> getProcess{ libmem::FindProcess(::processName.data()) };

    if (!getProcess.has_value())
    {
        std::cerr << "process not found\n";

        return 1;
    }

    const libmem::Process process(getProcess.value());

what do you think? new code should save some memory if i am correct, is my usage of ur library wrong? i know i can call getProcess.value() and have 1 variable but calling getProcess.value() on every function that uses libmem::Process can have impact

edit: ill stick to previous code, im not sure if changing the struct may give memory leaks

thesstraight avatar Jun 24 '25 17:06 thesstraight