« first day (629 days earlier)      last day (2448 days later) » 

00:00
to try and outsmart the compiler
Size_t is a unsigned int, how does that outsmart the compiler?
it stops the compiler from inferring that the value eventually returned is invalid as soon as you return
std::cout << (size_t)p; shouldnt it be std::cout <<(size_t) *p; ?
Since *p has the value
the value p points to doesn't exist anymore at that point
But its still pointing to a place in memory
And that place holds some value
Correct?
00:15
Dude, just give up on C++, horrible fucking language
36
not all memory is always readable
No need to be rude, plus i like this language alot
have you tried others?
large parts of the memory in an application is not mapped and trying to access that in any form leads to a immediate crash
00:16
Oh i see
Well i was just testing out something
don't play around with UB too much
Basicly i was curious about this pointer to a memory block i dont use thing
UB stands for?
all that teaches you is how that particular implementation does things
Undefined Behavior
Oh ok
Ratchet i have a question, you know about vector siza and capacity, and how the capacity grows by some ratio
00:19
I have a question about this, should i grow the capacity on a custom vector by a ratio or by fixed values?
For example
Capacity *= 1.5
Or capacity += 100
Its there a prefered option?
I was thinking and i think that the last option is more memory friendly
ratio means that doing repeated push_back will amortize to O(n), whereas fixed value means that will amortize to O(n^2)
But im not sure on wich to use, since most people use the first one (with diferent values)
Let me put this question in a diferente way, lets say i want to grow my capacity, should i grow it 1.5 times the size or should i grow it by size + (const int)
doing ratio 1.5 means that the max capacity is within 50% of the max size
that's good enough
Its that a better option then adding a fixed amount?
Because it the vector is verry big that would be a problem in terms of memory
getting away from the quadratic performance is worth it
00:26
What do you mean by quadratic performance?
O(n^2)
when growing capacity by += 100 then every 100 elements you will need to copy all elements in the array
adding n elements then means O(n^2) element copies required
So after 10 elements adding +100 would be more eficient
that will kill performance really quickly whereas doing *= will avoid that trap because as the array becomes larger it takes more elements before you need to copy all elements again
But the thing is, size would be one value and capa ity another
Wait, if my soze is 9 and i add 10, i would need 9 copies
So (assuming size is full) i would need size copies
For every time i in rease capasity
I dont see how doing += would kill performance rather then *=
Because in the end id would do the same amount of copies
Ohhh ok
I get it now, it gets bigger over time
Meaning its harder to fill it
My bad, im pretty tired, i should sleep
it reduces the amount of times you end up reallocating
00:36
@ratchetfreak thanks for explaining!
Yes i get it now
 
6 hours later…
06:06
Hello everybody, could I get some help with a linked list segmentation fault?
06:53
@Joey Ngo std::list?
 
1 hour later…
nwp
nwp
08:20
@JoeyNgo Put the code on coliru or some other site. Maybe online gdb makes particular sense in this case.
 
6 hours later…
13:51
Yo, I have weird issue. I have 2 projects they import the same libraries but one project is just 10 files for tests and other is 160. The large projects started crashing when I added another library. The errors are as follow :
:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\rpcndr.h(192): error C2872: 'byte': ambiguous symbol
c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\rpcndr.h(191): note: could be 'unsigned char byte'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\cstddef(22): note: or 'std::byte'
@Dariusz std::byte and the byte in rpcndr.h aren't compatible
you need to do what the note says
not sure what that means tbh
I didnt make any std::byte
this is full error stack pastebin.com/yqJg2pTB
mm I'm a bit lost
Not sure what I can do these errors are in windows kits libraries
JKS
JKS
14:07
Hello and Happy Easter!
Yo
Hmmm how can I do this "[H] /std:c++17 and /std:c++latest enable std::byte. It can be disabled by defining _HAS_STD_BYTE to 0."
Just write #define _HAS_STD_BYTE = 0; ?Where do I write that in ?
in main.cpp?
14:54
To any1 interested how to fix it, remove all namespace std and use std::. The rest works
15:47
@Dariusz /D _HAS_STD_BYTE=0 or something like that. In Visual Studio, on your project, right click > properties > C/C++ > Preprocessor > Preprocessor Definitions. I think you just write _HAS_STD_BYTE=0 there
I'm using cMake
no VS properties
Then it's target_add_definitions
16:24
I think it's actually target_compile_definitions
Yeah, it would be target_compile_definitions(myTarget VISIBILITY _HAS_STD_BYTE=0) where VISIBILITY is the appropriate visibility (PUBLIC, PRIVATE, INTERFACE, etc)
And you could make that target_compile_definitions(myTarget VISIBILITY $<$<CXX_COMPILER_ID:MSVC>:_HAS_STD_BYTE=0>) and it would only add the flag for MSVC
 
5 hours later…
21:39
@Dariusz someone's using using namespace std; because otherwise this wouldn't have happened because std::byte is in a namespace
@Dariusz Oh yeah
Now you know one of the reasons why people complain about using namespace std;
 
2 hours later…
23:26
would this be a good option if i wanted my program to do nothing until p != org ?
do {} while(p != org)
or is there a better option for that?
is doing something like this: do {} while(p != org); a good approach?
use a condition variable
what do you mean?
well i should mention that (if my program works correctly) the value of p will change without me telling it do change
im still experimenting on UB basicly
im just still curious about the pointing to memory thing
this is what im trying to do:
auto _mem_get()
{
	auto k = 5;
	unsigned int _k;
	std::cout << &k  << "\n";
	std::cin >> std::hex >> _k;
	return _k;
}

int main()
{
	int i = 0;
	unsigned int *p_addr = (unsigned int *)_mem_get();
	unsigned int org = 0;

	std::cout << "\n p_addr = " << p_addr << " = " << *p_addr << std::endl;
	org = *p_addr;
	do
	{
	} while (*p_addr == org);

	std::cout << "New value of *p = " << *p_addr;
	return 0;
}
im trying to see if the value in memory changed somehow
and i print the new value of it
maybe other function used that address, idk, im just curious if i can catch that using that do while loop
will this my code do what i think it does?
23:53
there is nothing that will change the value so you will end up in a inf loop always
what is the memory value changes?
wont *p_addr change also?

« first day (629 days earlier)      last day (2448 days later) »