Stephanos
mh
Stephanos
i guess we have different opinions on that :)
Artöm
Yeah, then we say, that it is good to have a lot of little simple functions. We do int calc() { int r{ 0 }; // some shit return r; } constexpr int important_var{ calc() }; // duh
Artöm
Thing is, we can't explain constexpr as "just slap it somewhere, it's a good stuff"
Artöm
I think constexpr is even easier to explain than plain const
Rly? Then say what type s has in constexpr char* s{ "str" };
Artöm
To a person who isn't sure how to use if
Francisco
Rly? Then say what type s has in constexpr char* s{ "str" };
constexpr doesn't really say anything about the type like const does. It just tells the compiler that the value has to be known at compile time
Francisco
And why this is a compilation error
Because you didn't mark the function as constexpr
Artöm
Because you didn't mark the function as constexpr
Now list all the conditions a func must meet to may be evaluated at compile time
Artöm
It may be harder than virtual functions
Francisco
Now list all the conditions a func must meet to may be evaluated at compile time
You can find them in cppreference. In C+11 were restricted to a single return statement, but they relaxed that in C++14. You can do pretty much anything that doesn't involve dynamic allocations
Artöm
Now list all the conditions a func must meet to may be evaluated at compile time
Remember, we're talking about novices: people, who hasn't even heard about classes e.g. They're struggling with unformatted text output
Francisco
It's as simple as "constexpr implies compile time execution instead of runtime"
Francisco
If you have constexpr int sum(int lhs, int rhs){ return lhs + rhs; }, what you're telling the compiler is "Hey, do this at compile time if you can"
Francisco
In C++20 we will have inmediate functions, which will be marked as consteval. This forces the function to be executed at compile time
Artöm
You can find them in cppreference. In C+11 were restricted to a single return statement, but they relaxed that in C++14. You can do pretty much anything that doesn't involve dynamic allocations
First bullet: > its return type must be a LiteralType Okay. Let's take a look > possibly cv-qualified (da hell?) void Well, that's relatively easy to google > trivial dtor, aggregate, closure Et cetera
Artöm
It may sound easy for one who faced this things a lot
Francisco
One need to know hella lot terms and principles to understand conxtexpr conditions
I don't even understand all of them. I just program functions normally, mark them as contexpr and wait for the compiler to tell me what's wrong and adapt as I go
Francisco
Just avoid dynamic allocations and you're good to go
Francisco
They're not used for everything, but if you think your function is quite simple, just mark it as constexpr and the compiler will execute at compile time everytime it can
Francisco
It's not that difficult. You just want to know EVERYTHING, which isn't really necessary
Artöm
> mark them as contexpr and wait for the compiler to tell me what's wrong and adapt as I go That's a way actually. But what we want them to learn is const. And slapping constexpr everywhere explains neither const nor constexpr
Artöm
I admit I may've crossed a line, but I do think every single word in a program should be clear to one who writes it, especially if one learns a language
Francisco
Isn't the keyword constexpr clear enough to you?
Artöm
Isn't the keyword constexpr clear enough to you?
It's clear as a term, but not it's usages and restrictions
Artöm
Like, with C++20 we will be able to do constexpr funcs virtual and have try blocks inside
Artöm
There are similar differences in 11/14
Francisco
It's clear as a term, but not it's usages and restrictions
There's few restrictions. An important one is that the code can't invoke undefined behaviour, which is pretty sensible
professor
hey guys , is there a way to buggy a directory list crawler in c++?
...
what?
professor
I coded a a function to find all files , directories , and sub directories with its files , but at the moment to change it to D: second hard drive it skips some folders
professor
C:\Users\blackleitus\Documents\xxxx\strix\Release>strix.exe D:\\poc.c D:\\things.txt D:\\blackleitus\Videos\movies\No Reservations (2007) [BluRay] [720p] [YTS.AM]\No.Reservations.2007.720p.BluRay.x264-[YTS.AM].mp4 D:\\blackleitus\Videos\movies\No Reservations (2007) [BluRay] [720p] [YTS.AM]\No.Reservations.2007.720p.BluRay.x264-[YTS.AM].srt D:\\blackleitus\Music\ C:\Users\blackleitus\Documents\xxxx\strix\Release>D: D:\>dir Volume in drive D is Bk-Storage Volume Serial Number is 7AC4-6C0A Directory of D:\ 06/30/2019 12:30 AM 1,346 poc.c 06/30/2019 12:30 AM 210 things.txt 05/30/2019 04:45 PM <DIR> blackleitus 2 File(s) 1,556 bytes 1 Dir(s) 961,850,376,192 bytes free D:\>cd blackleitus D:\blackleitus>dir Volume in drive D is Bk-Storage Volume Serial Number is 7AC4-6C0A Directory of D:\blackleitus 05/30/2019 04:45 PM <DIR> . 05/30/2019 04:45 PM <DIR> .. 05/27/2019 11:33 PM <DIR> Documents 05/22/2019 07:54 AM <DIR> Pictures 05/22/2019 12:56 PM <DIR> Music 04/25/2019 11:07 PM <DIR> Videos 0 File(s) 0 bytes 6 Dir(s) 961,850,376,192 bytes free
professor
this is what I am talking about
...
what IDE are you working on?
professor
visual studio 2019
...
include windows headers, put a system("pause"); at the start of main, and run it in the console, then go to vs, press ctrl + alt + p and select your program, now press any key in the console and you got a debugger attached
professor
it works as indeed because if I change the location to D:\username\\Documents it works well
professor
it just skipt some folders
...
step through the code and see why it skips it
...
i doubt its any mistake in the api
Liam
Anyone could help at this question would be appreciated: https://stackoverflow.com/questions/56880708/unexpected-compile-error-in-c-passing-default-value-to-function-parameter
kλletaa
nice name
kλletaa
and nice meme
Mihail
Yeah, then they might do constexpr std::string prefix{ "$HOME/myspace/" };
https://en.cppreference.com/w/cpp/string/basic_string_view
just a normal few
Halp fore it
professor
before coding . learn how to ss or use github to store code , and trace error
just a normal few
Tanks but this exercise is finaliayed for it
Mihail
?
Mihail
also your error is so trivial it's not even funny
just a normal few
Holy Shit
Hi, guys
just a normal few
I have results 3 error
Stephanos
I know but for me it so difficult
It is, you are simply too lazy to read your own code
Mihail
I have results 3 error
look at the line above the highighted one
Mihail
like you can't miss it
just a normal few
I have results
just a normal few
Tanks
just a normal few
Halp guys I have an "error" when I put the variable before it's an Ù
Mihail
first show a screenshot/pastebin of your code and explain your problem
Mihail
then we could help you
just a normal few
Ok
just a normal few
Andrea
🙈
just a normal few
just a normal few
just a normal few
Sorry for the Italian
Mat
Screenshot or pastebin
Mat
Not this
just a normal few
It's a photo
Mat
And it's useless for us
just a normal few
Why?,
Mihail
i already warned you to not send photos of screens
Andrea
It's a photo
do a screenshot: use a program that capture your screen (or a portion of it), save it as an image, send the image here