Anonymous
yes https://pastebin.com/kj3VF2z3
the CarBuilder object seems to be capable of creating Car objects. is it not capable of destroying them?
Sergey
the CarBuilder object seems to be capable of creating Car objects. is it not capable of destroying them?
Yes It can create but not destroy As I understand Builder pattern not supposed to destroy objects
Anonymous
Hello
Anonymous
Can someone please help me with C++?
Anonymous
Nils
Hi, can somebody recommend a flask-like framework for C++?
infi ptr
i am getting Segmentation fault for this code, can anyone help ?
Nils
i am getting Segmentation fault for this code, can anyone help ?
First upload code to pastebin/hastebin so we can read/debug it better
Hermann
i have char a_size []="xxxx" and char a[4], why fegts over a, why fgets(a, 5, stdin) delete a_size?. is a null pointer the problem?
Nils
https://pastebin.com/rei84JrR @Nils
Okay, I'll take a look
Nils
https://pastebin.com/rei84JrR @Nils
tip when using "\n": You should use just '\n' as it's one single character
Nils
For performance etc
Nils
I am still debugging…
Anonymous
Can I send you invite link to gitlab? Cause there are not so little files
sure i guess. working on something besides book exercises seems like a fun idea
Anonymous
yes https://pastebin.com/kj3VF2z3
i made some changes to your code, but can't really compile it without rest of the sources
Sirr Dessy
please i need help with this
Anonymous
Hi, can somebody recommend a flask-like framework for C++?
https://github.com/ipkn/crow last commit 2017 though
Javi
i am getting Segmentation fault for this code, can anyone help ?
You are making the iterator invalid inside the for loop.
infi ptr
You are making the iterator invalid inside the for loop.
what i should i fix to eradicate that ? lil bit confused.
Javi
If the container is going to change inside the loop, don't use iterators
Anonymous
hii🥳
Anonymous
so you tell me
Anonymous
Anonymous
guys program not run
Anonymous
you tell me why should not run
I_Interface
guys program not run
What the problem to use debugger ?
Anonymous
i dont know
I_Interface
i dont know
use it and u shall see
Anonymous
i very try it
Anonymous
how become run
Anonymous
auto keyword error showing in this program
Anonymous
please guys tell me today/tomorrow plz
Anonymous
okk see u
Nils
Why is that impossible: std::map<std::string, std::function<void()>> testmap; testmap["blah"] { // Some code } ?
Nils
Is there some way to get it to work?
Anonymous
Why is that impossible: std::map<std::string, std::function<void()>> testmap; testmap["blah"] { // Some code } ?
> Why is that impossible std::function isn't a function declaration, it just holds pointers to other callable objects that already exist
Anonymous
Is there some way to get it to work?
yes. lambdas can be assigned to testmap["blah"] =
Nils
So I can't use it to store functions/create function and store pointer directly inside maps?
Nils
That makes no sense, what would happen to }?
Anonymous
do you know how to write lambdas?
Nils
Nope
Anonymous
Nope
https://en.cppreference.com/w/cpp/language/lambda
Nils
Okay, wait…
Nils
// some code isn't enough :/
testmap["argv"] { // Check amount of arguments if (args.size() != 1) { return badarguments; } // Check argument auto argsit = args.begin(); if (!is_float(*argsit)) return badarguments; // Get argument float sleepsecs = std::atof((*argsit).c_str()); sleep(sleepsecs); return success; } Is that enough?
Nils
Okay, thx
Anonymous
this is quite large for a lambda. just write a function and assign the name to testmap["argv"]
(not that you can't write a lambda this large, just that it would be unusual. further, the function looks stateless which is another reason to not use a lambda)
Nils
this is quite large for a lambda. just write a function and assign the name to testmap["argv"]
So I tried this now: #define command_args std::vector<std::string> args #define command_rawtmpl(func) func(command_args) #define command_tmpl(func) std::string command_rawtmpl(func) typedef std::function<command_rawtmpl(std::string)> command_type; std::map<std::string, command_type> commands; #define command_register(func) commands[#func] = func; ... command_tmpl(whatever) {...} command_register(whatever); But it results in: source/pilang2.cpp:123:32: error: ‘commands’ does not name a type 123 | #define command_register(func) commands[#func] = func; | ^~~~~~~~ Why?
Nils
For some reason my code looks like spaghetti inside Telegram 🤔 Look at it inside some IDE
Anonymous
ohhhh
Nils
With macro magic
Nils
it's right. You don't need the # for values
But it has to be converted to a string
Nomid Íkorni-Sciurus
you only need # for renaming left-side symbols
Nils
oh okay
Nomid Íkorni-Sciurus
still same error
show me how you wrote it
Nomid Íkorni-Sciurus
^
You have to remove the #
Nomid Íkorni-Sciurus
and?
Nils
and?
It changed nothing
Nomid Íkorni-Sciurus
It changed nothing
let's see the "nothing" Show both code and error
Ludovic 'Archivist'
Nils
Ahhh I have to do the assignment inside a function!
Nils
please stop using the preprocessor for anything other than #include and feature test macros
But it adds flexibility 🙄 Imagine that you want to change which arguments these functions receive. You would have to change every single function definition…
Nils
Like that you have one, single place where you can modify such