Israel
#include <iostream> using namespace std; Int main() { cout<<"Hello World"; return 0; }
I'm a newbie to c++ and I'm faced with lots of error messages. I don't know what to do;Please guys your assistance on this is highly needed🙏🏽
Anonymous
I'm a newbie to c++ and I'm faced with lots of error messages. I don't know what to do;Please guys your assistance on this is highly needed🙏🏽
Bro in starting u will face error only Don't think too much it's normal Try to find out why those errors are coming
Anonymous
#include <iostream> using namespace std; Int main() { cout<<"Hello World"; return 0; }
#include <iostream> using namespace std; int main() { cout << "Hello World"; return 0; }
Anonymous
U have written Int but u have to write it int because it is a keyword
Yra
/start@MissRose_bot
Azadi
No, a constexpr variable must be initialized with a constant expression So, it's always initialized at compile-time and can be used in other constant expressions So, it's always evaluated at compile-time
I believe constexpr conveys always only a possibility to be evaluated at compile-time, unless you use static constexpr. And yes, consteval is not for variables or static data members.
The
Can't template because I can theoretically store tens or hundreds of permutations of types, wouldn't want to make all them as template arguments of the class
Nice point.. but you have to use it judiciously.. If you're thinking it will explode the no of functions.. it won't if you design it properly.. using type erasure and wrap stuff.. basically any works like this.. so suppose you should use any over raw pointers..
The
And the other thing you should almost never prefer void* or std::any to templates
Isn't std::any a template based wrapper ? Why not use that? Edit: ok coz value copy ..
dearfl
The
i think std::any is not a template but a type erasured type?
Yeah.. that in itself would've been alright for most use cases... But it allocates memory and copies value.. but prob someone out there wrote a reference copy version
az
This could help (look at the part titled Disruptor) https://archivist.nekoit.xyz/fast-logging/
Thank you, but i already know the answer. Producer tail used in calculation of max number of elements that are ready to be dequeued
Ludovic 'Archivist'
I believe constexpr conveys always only a possibility to be evaluated at compile-time, unless you use static constexpr. And yes, consteval is not for variables or static data members.
No sane compiler would push errors to be detected at runtime, and if a compiler was dumb enough evaluate constexpr variables at runtime, it would also require template evaluation at runtime, as constexpr variables are absolutely usable as template arguments. It would also make constexpr variables unusable in static assertions
Ludovic 'Archivist'
Thank you, but i already know the answer. Producer tail used in calculation of max number of elements that are ready to be dequeued
Yes, basically, you use several atomics to delimitate different regions that are interacted upon differently
az
Yes, basically, you use several atomics to delimitate different regions that are interacted upon differently
Are you familar with dpdk rte_ring primitive? Just i have got some other question about that
Danya🔥
What's the resource for that claim?
I've already explain you why
Danya🔥
https://t.me/programminginc/500668 https://t.me/programminginc/500669 This is the standard ☝️
Azadi
I've already explain you why
Because of constant literals?
Danya🔥
https://t.me/programminginc/500670 This is basic knowledge about compilers
Azadi
If the reason is that, so something like int a {5}; will also be evaluated at compile-time since 5 is a constant literal!
Azadi
I'm shocked you neither agree with standards nor cppref!
Danya🔥
If the reason is that, so something like int a {5}; will also be evaluated at compile-time since 5 is a constant literal!
If it's not changed during the execution, it also will be propagated Yet a itself is not a constant expression
Danya🔥
Danya🔥
But the standard is not the "truth" per se
Danya🔥
You live in a real world while the standard is not
Danya🔥
I'm shocked you neither agree with standards nor cppref!
Can you please give at least one example when a constexpr variable is not evaluated at compile-time? Real world example
Danya🔥
Also, appealing to authority is a form of logic error, so "Turner said so" is not an argument
Azadi
Can you please give at least one example when a constexpr variable is not evaluated at compile-time? Real world example
There's a subtle difference in between. I didn't say a constexpr variable cannot be evaluated at compile time; I said, or better, by standard, it can be and most of the time it is in practice. To put in a nutshell, it's an opportunity not certainty.
Danya🔥
I said that it is ALWAYS evaluated at compile-time You said that's not true So I ask you for a real-world of a constexpr variable evaluated at runtime
Danya🔥
C++ is defined not only by the standard but by the real world too It's time to "turn on" your head and think why the fuck a thing that ALWAYS initialized at compile-time (that's the standard btw), we'll be sometimes evaluated at runtime.
Danya🔥
You can be happy with your head so-called turned on while your claims don't apply with standards. I tend to rely upon standard. Enough
Do you understand that there's no implementation of C++ that actually aligns with the standard?
Danya🔥
It's so foolish "to rely on the standard" because C++ is defined by both the standard and the real world, as I already said
Danya🔥
Anyways, living in an imaginary world must be fun
Pavel
Nice point.. but you have to use it judiciously.. If you're thinking it will explode the no of functions.. it won't if you design it properly.. using type erasure and wrap stuff.. basically any works like this.. so suppose you should use any over raw pointers..
Well "design it properly" also means not to overcomplicate. I see trying to move everything to compile time is overcomplication here. Type erasure yes, but that's what I'm basically implementing with void*. Note that void* is not exposed to the user, it is an implementation detail, and what I want to do now is to hide it even in the classes that I use internally, so the complexity is contained even more.
Pavel
What I basically wanted to know is whether it is safe to static cast void*[] to MyClass*[] (assuming MyClass pointers is what is stored there). I've got an answer that it is not safe(and requires reinterpret_cast), I'm happy with that answer and not going to look further. But now I have to protect my design decisions of the whole library for some reason.
Pavel
Damn, telegram doesn't allow me to write ** twice even in code blocks
mito
Damn, telegram doesn't allow me to write ** twice even in code blocks
It's a shame that telegram web has syntax highlighting and it's not available on the official client yet.
Ludovic 'Archivist'
It's so foolish "to rely on the standard" because C++ is defined by both the standard and the real world, as I already said
Well following the standard has the pro of being multiplatform, it also has the con of making you completely paranoid
Danya🔥
Well following the standard has the pro of being multiplatform, it also has the con of making you completely paranoid
I agree with following standard I just don't agree that it's the only truth and C++ is only limited by it.
Ludovic 'Archivist'
I agree with following standard I just don't agree that it's the only truth and C++ is only limited by it.
Microsoft learned that dire truth when they had to reimplement templates from scratch in 2016
Ludovic 'Archivist'
Microsoft learned that dire truth when they had to reimplement templates from scratch in 2016
(also they were not quite following the standard already with that so it was a good sting in their asses)
Danya🔥
We live in a world where compiler developers can understand the standard the way they want to The standard is the good thing, yet it's not the only way how C++ is defined There is no C++ implementation that 100% follows the standard because it's technically impossible
Danya🔥
So when writing code you need to use your knowledge about the world and not blindly believe the standard
Ludovic 'Archivist'
We live in a world where compiler developers can understand the standard the way they want to The standard is the good thing, yet it's not the only way how C++ is defined There is no C++ implementation that 100% follows the standard because it's technically impossible
Yes, I was just poking some fun at Microsoft doing something differently from literally anyone else that changed the semantics and usage of wide parts of the language. (when I mean everyone else, I mean gcc, clang, IBM, cray, digital mars, Nvidia at the very least)
Danya🔥
Yet in the last years they are pioneers of the C++ standard
Ludovic 'Archivist'
Yet in the last years they are pioneers of the C++ standard
Well, they had to rewrite a lot of the compiler so they made it more maintanable
...
Yet in the last years they are pioneers of the C++ standard
ever worked with c++/clr? it's one of the biggest messes I've seen
Ludovic 'Archivist'
ever worked with c++/clr? it's one of the biggest messes I've seen
I used it, I hate it, but it had a very significant performance benefit compared to regular MS VC++
Ludovic 'Archivist'
what on earth... how..
The runtime would run the optimizer upon launching the code again, with native specific optimizations on, giving around 12% of improvement on several of my test loads, and no loss on other loads
Danya🔥
Well first of all MSVC optimizer is a joke Then, you should've compiled with something like -march=native
Then even if it'd have a performance benefits, they wouldn't be so drastic
Danya🔥
i wonder if you could've achieved the same thing using any other language with a tracing jit, luajit for example
Sure, sometimes jit programs are faster than their native counterparts But it's more like luck than the pattern
Ludovic 'Archivist'
did you benefit from the features CLI provides at all?
Not much, just in the easier interfacing with C#
Ludovic 'Archivist'
Well first of all MSVC optimizer is a joke Then, you should've compiled with something like -march=native
I didn't have control on what servers the code would run on, and it would run on servers that I didn't know the architecture of
...
Well first of all MSVC optimizer is a joke Then, you should've compiled with something like -march=native
fun thing, their optimizations (even when talking about architecture independent things) are much better when targeting x64 than when targeting x86. i wonder what kind of crap is going on under the hood for such a thing to occur
...
https://gcc.godbolt.org/z/sWdPxo861
there's no reason for something like this to ever happen
\Device\NUL
Hello, I want to using native api on Windows. I've tried phnt headers but it shows error. Can you guys suggest me a native api for windows header?
Saeed
How can I access global variable from function only in the same module without changing the signature of the function.
Saeed
May you give an example. I'm not sure I understand what you mean.
int foo; foo = 5; Int bar() { return foo;} bar() // return 5 foo = 6; bar() // return 6 // This kind of functionality
Alex
You cannot chenge wariable out of function scope.... C++ is not a script language. It runs in function body only.
Alex
If you will wrap first bar and second bar with the function you will get an axpected result.
Alex
Extern you need when you have more then one cpp file or more then one module. So you will told to the compiler that you will bring the address of the variable during the linking and not at the compile time.
Pavel
How can I access global variable from function only in the same module without changing the signature of the function.
If you are talking about C++20 modules, then there is some module linkage. https://vector-of-bool.github.io/2019/10/07/modules-3.html If by "module" you refer to a translation unit, you can mark the global variable as static or put it in an unnamed namespace (it should be declared in *.cpp file, not in *.h), then it will be available only in the translation unit where you declared it (and if you declare it in different translation units, each unit would have its own instance of the variable). Note that such variables are tricky to manage, and any global variables are in general.
Anonymous
You cannot chenge wariable out of function scope.... C++ is not a script language. It runs in function body only.
Ohk . it is not in c In c only const variable cannot be change when it's in romb