V01D
C++ question.
Which is better, auto oder templates?
I know that templates are more "universal" in that it is a reusable data type, but I'm kinda confused on which to use.
V01D
Mar!o
Okay, thanks.
Np^^
I really love auto but you should not overuse it because it can makes code even harder to read if you hide all the types away
V01D
Chinaka
What the best place to start when someone wants to start learning C++
Chinaka
V01D
Chinaka
V01D
No problem
Talula
V01D
V01D
Sorry, just ask your questions in here
Dima
Anonymous
Cool open source small libraries that can help anyone in project.. https://github.com/CoolerVoid/Fortress-of-Solitude
Ибраги́м
https://vector-of-bool.github.io/2020/10/26/strong-bool.html
Anonymous
Interesting
Ибраги́м
sphere991 EWG:
https://www.reddit.com/r/cpp/comments/jj48jm/fun_with_concepts_do_you_even_lift_bool/gabbejf?utm_source=share&utm_medium=web2x&context=3
boolean(true) == boolean(true) actually shouldn't compile per C++20 rules (it's ambiguous between which one you want to convert, which makes sense conceptually). Neverthless, because reasons, gcc accepts it anyway and clang just issues a warning.
But for the "another solution", any problem can be solved by an extra layer of indirection:
template <typename T>
struct Exactly {
Exactly(std::same_as<T> auto v): value(v) { }
operator T() const { return value; }
T value;
};
This lets you write:
void foo(Exactly<bool>); // no longer a template
Which is something that we've used in a bunch of places to solve this problem and it's proven to be quite useful.
Ludovic 'Archivist'
Ибраги́м
Oh I love that
#MeToo.
My brain was thinking something simple after reading the article.
But boy oh boy that sphere991 did it.
Noble Friend
Hi everyone.
Uhh, I've got a question, how do you know/decide when to use OOP in your program.
Consider you are writing a program in C++, when do you decide to use the OOP concepts?
I'm kinda confused.
Thanks in advance🙂
Ludovic 'Archivist'
Anonymous
Anonymous
Sasuke
Noble Friend
Noble Friend
OK thanks
klimi
What do you need Dilisha?
Arminio
type -p xprop &>/dev/null && {
id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)
id=${id##* }
wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t)
wm=${wm/*WM_NAME = }
wm=${wm/\"}
wm=${wm/\"*}
}
I would love to write this here in C, but I have zero clue how to do all the string processing in C.
Arminio
Anything reasonable I should read?
Wojak
Dima
lol spam
Anonymous
Arminio
What is this ?
That BASH snippet just reveals the name of the window manager currently running.
Anonymous
Can someone provide good resource to learn c++ unit testing. I have quite good knowledge but I have zero knowledge of testing and TDD
Anonymous
Anonymous
yes i got the framework but i dont know where to learn
Anonymous
hi
Anonymous
Does anyone know the answer to this question?
Anonymous
The below represents an encoded list of 10 esoteric programming languages. What is the name of the second language?
68747470733a2f2f6465762e746f2f617777736d6d2f32302d696e7472696775696e672d756e757375616c2d616e642d676f6f66792d70726f6772616d6d696e672d6c616e6775616765732d32333866
Anonymous
How do I solve it?
Talula
Anonymous
Anonymous
hi
Anonymous
is it more performant to use floats with less decimal places?
Anonymous
say if I have a float of 12 decimals places vs 6
Talula
are you sure?
What is that? Just a string of numbers and letters...
Anonymous
Anonymous
Anonymous
Alex
double faster than single?
Mar!o
It really depends on the hardware. But with SIMD floats would be faster as we can crunch more...
olli
do you have any source for this? addss and addsd have (according to intel) the same latency and throughput
Alex
even so, double occupies more memory, getting data from RAM is usual bottleneck today
olli
To be honest, I don't think he meant the difference between double and floats tho, because there is no way to manually "set" the number of decimal places
olli
Intel reference for addsd and addss
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=addss&expand=154,158
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=addsd&expand=154,158,154
Anonymous
well a float can hold more than 7 decimal places
Anonymous
I was wondering if operations on floats with more decimal places was slower
olli
but that's the point, why would it be faster?
olli
i would imagine its more efficient to calculate with shorter floating points
If I understood Madhu's statement correctly, he said on modern hardware double precision would be faster than single precision and I doubt that (not considering vectorization but operations on a single floating point value).
When you operate on floats you can't tell your CPU to only consider n decimal places, that's basically what the "float" means. The decimal places depend on your actual number.
Anonymous
some one actually made an argument recently that float's are still more performant that doubles on modern systems
Anonymous
bit of a mystery really the old FPU huh ?
olli
For the A100 it looks like SP is still faster than DP
Peak FP64 9.7 TFLOPS
Peak FP64 TCore 19.5 TFLOPS
Peak FP32 19.5 TFLOPS
Peak FP16 78 TFLOPS
Peak BF16 39 TFLOPS
Peak TF32 TCore 156 TFLOPS
Anonymous
i only use doubles for high precision arithmetic and then cast to float, get's more accurate float representations
Anonymous
I do actually hit my max memory bandwidth so, processing floats is better for me
Sunflower
Hello everyone :)
Sunflower
I came upon this group while trying to find out someone to help me learn. I am a beginner in learning coding and m struggling with the very basics.
Sunflower
I wrote this code today to try to understand how to print value in next address
Sunflower
I am not understanding how to correct it
Sunflower
I hv taken inputs as 4 and 5
M.Khorram
change your code to see the address that p is pointing to:
std::cout << n << " " << *p << " " << p << std::endl;
std::cout << n << " " << *p++ << " " << p << std::endl;