BinaryByter
if it doesnt change the stabdard, why is there an infinite loop in O3?
olli
Optimization doesnt change the standard
true, but the outcome of UB might change
BinaryByter
true, but the outcome of UB might change
Oh okay. What about my code was ub though?
olli
if it doesnt change the stabdard, why is there an infinite loop in O3?
your code handles multiples threads and isn't even thread safe.. cmon
BinaryByter
Oh right yea
BinaryByter
oh yea fuck i forgot that one mutex
BinaryByter
I'm a potato
Nomid Íkorni-Sciurus
lol
olli
"I'd rather clame the compiler" ¯\_(ツ)_/¯
BinaryByter
it was a nice try, right?
olli
And the design is strange....
BinaryByter
mhh
olli
unsigned int isn't thread-safe either
BinaryByter
it is not?
olli
it is not?
how should it?!
BinaryByter
well... read only should be thread safe, right?
BinaryByter
Wait, i have an unsigned int in my thread code?
Anonymous
well... read only should be thread safe, right?
yes, because it is a atomic operation
olli
dispatcher is of type unsigned int
olli
well... read only should be thread safe, right?
concurrent reads are always kinda safe
BinaryByter
dispatcher is of type unsigned int
i have a dispatcher in my code? wat?
BinaryByter
Oh this dispatcher
BinaryByter
concurrent reads are always kinda safe
Yea, well i only write it from one thread
many
When to use reference and when to use pointer?
olli
When to use reference and when to use pointer?
As a rule of thumb (it always depends though) Use pointers if - you need a value type (reference wrapper would do as well) - null is valid - you need to reassign them - do arithmetics otherwise use references
Prometheus
Prometheus
No references needed
Prometheus
Literally nothing wrong with them if you know what you’re doing.
BinaryByter
No references needed
thats the spirit!
olli
Yea, well i only write it from one thread
since runFunction is public.. how can you be sure?
many
Does the original value change with its reference?
BinaryByter
since runFunction is public.. how can you be sure?
I should add to the docs that threadScheduler isnt threadsafe
olli
I should add to the docs that threadScheduler isnt threadsafe
sounds error-prone and sub-optimal for a public API to me...
many
yes
So I would say reference is essentially pointing to an allocated memory. Mmm... Isn't reference doing the same as pointer does?
olli
So I would say reference is essentially pointing to an allocated memory. Mmm... Isn't reference doing the same as pointer does?
Yes, but - you cannot change what the reference refers to - it can't be null - does not support arithmetics
BinaryByter
Yes, but - you cannot change what the reference refers to - it can't be null - does not support arithmetics
in modern cpp you shouldnt want a pointer to be null. optional is a far better choice, imho
olli
1) what about T &a = var; a = var1; ?
that's fine, it assigns the value to what it refers to. But you cannot change what a refers to
BinaryByter
ah thats what you mean
BinaryByter
okay yea
Nomid Íkorni-Sciurus
Noble Friend
I'm human already
S.H
Hi
Noble Friend
Hi
Dima
welcome
Anonymous
Anonymous
how can we do this
Dima
What the..
Anonymous
Processing in console
Dima
What?
Dima
what the...
klimi
Bot...
klimi
I should add that my dictionary
infi ptr
In hackerrank test platform is it must to implement vectors in c++ ??
klimi
infi ptr
Wdym?
Is it must to implement vectors with c++ ?
olli
Is it must to implement vectors with c++ ?
https://www.hackerrank.com/environment For the standard challenges g++ 8.2.0 is available (including the std library)
Deepak
Hey everyone
infi ptr
https://www.hackerrank.com/environment For the standard challenges g++ 8.2.0 is available (including the std library)
#include <bits/stdc++.h> #include <algorithm> using namespace std; void miniMaxSum(long long int arr[]) { sort(arr, arr+5); int min, max; int sum=0; for(int i=0;i<5;i++) {sum=sum+arr[i];} min=sum-arr[4]; max=sum-arr[0]; cout<<min<<" "<<max; } int main() { long long int arr[5]; for (int i=0;i<5;i++) { cin>>arr[i]; } miniMaxSum(arr); return 0; } this is my code,and [256741038 623958417 467905213 714532089 938071625] is getting fail
Anonymous
hiii everyone
Bhupesh
https://dev.to/bhupesh/30-seconds-of-c-4egn
klimi
https://dev.to/bhupesh/30-seconds-of-c-4egn
Is it a promotion ? @BinaryByter @Ariana1729
BinaryByter
No
BinaryByter
this is fine
klimi
Okay
Ariana
hard to tell tbh but code quality not bad
Anonymous
What is an array
joel
What is an array
a data structures of sequential elements of the same data type