« first day (254 days earlier)      last day (2590 days later) » 

6:27 AM
when do i need pthread_exit?
 
7:01 AM
i understand
 
 
1 hour later…
 
3 hours later…
10:47 AM
Hi guys
thank you for replying about the iterator stuff
is that interface wrong?
I'm not sure whether I should inherit from some iterator class in the stl header files
or that interface is fine
 
 
4 hours later…
2:19 PM
hi there
 
why i don't see memory change after doing lots of pointers with data and deleteing them?
for example, the memory usage of a process started with 1MB
and it started growing to 5MB
 
Xeo
Kids, don't do lots of pointers.
 
so that's how they call it these days?
 
i don't mean what u think
i've tcp server
on every connection new pointer is created
after 1k connection the memory usage is 5MB
 
Xeo
2:24 PM
11 messages moved from Lounge<C++>
 
hello there
i've tcp server
on every connection is created new pointer
after 1k connections memory usage is 5MB
 
nwp
@SzymonMarczak Because it is inefficient to give memory back to the OS and then request it again later. It is more efficient to just keep the memory and give it back when you request it again, bypassing at least 2 OS-calls, so that's what modern systems do.
 
@nwp oh i see
so after deallocating memory the runtime keeps it?
 
nwp
@SzymonMarczak Mostly, basically, depends on the runtime and the OS and how much memory and how the stars align. Don't worry about it.
 
okay
what about if the memory usage is 1GB and was deallocated and then another process requested 1GB of data?
will it use the memory deallocated by the first process?
 
2:30 PM
what you usually see happen in a program's memory usage is that it grows to some value and then stabilize
 
nwp
@SzymonMarczak maybe
 
@SzymonMarczak no the OS will use the swap space on the disk to save the memory of another process and then return a new blank page
 
@ratchetfreak oh, that's great!
thanks 4 help :)
 
there are ways the runtime can say "I'm not using this memory anymore for a bit free discard if you need to" but that requires a syscall
so that when it's requested again you get the same page back
possibly cleared depending on "stuff"
 
2:32 PM
i understand now
 
 
1 hour later…
3:41 PM
Why is const_cast a thing? I mean if you see const you know that thing will stay as it is. But if you do const_cast that just conmpletely removes that certainty.
 
hi everybody
 
Feb 23 at 13:53, by milleniumbug
const_cast is precisely for dealing with shitty non const correct APIs
 
Yeah, just found that
 
nwp
yesterday, by nwp
Read the Rules! TLDR: Questions go here.
 
3:42 PM
could you tell me why the compiler crashes compiling this code??
 
So that is it's only purpose?
 
4 messages moved from Lounge<C++>
@kim366 yes
 
@user3770392 Compiler crashes? Your compiler is broken. Report a bug.
 
I mean the worst is `void Foo::bar(int x_) const
{
const_cast<Foo*>(this)->x = x_;
}`
lol
 
nwp
@kim366 you can use it do add const too, and sometimes that helps when you have a const and a non-const-version of the same function.
 
3:43 PM
hahah
 
@user3770392 crashes? displaying "internal compiler error" and like?
 
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.
 
so you found a bug in the compiler. congratulations
 
yep
 
internal compiler errors are always bugs
 
3:44 PM
but is that correct code in your opinion?
internal compiler error: in tsubst, at cp/pt.c:11313
 
nwp
@user3770392 ideone doesn't like it
 
...it doesn't really matter whether it is correct or not. if the compiler says "internal compiler error", and says "please submit a bug report", it's the compiler problem, always
 
nwp
or maybe it wasn't complete, seeing that the code failed to compile due to missing includes
 
I m using a gcc version < 5
probably it has been corrected
 
so try with a newer version then
 
nwp
3:47 PM
there is a chance that the code compiles correctly once it is correct, but the better solution is to just use a newer compiler
 
@nwp so you're saying the code is not correct? yes, I agree.. problem is that I must use this compiler
 
yes, in any case this means your code is too complicated and you need to reduce it
 
nwp
@user3770392 See if you can get it to work on ideone or coliru.stacked-crooked.com
 
@mil
@milleniumbug please define complicated? I need to do exactly what I'm doing there :)
@nwp: are you saying: with a complete main?
 
don't use template metaprogramming from hell
 
nwp
3:51 PM
@user3770392 yes. Alternatively you can use godbolt.org which doesn't really need a main.
 
@nwp seems to only complain about missing main after adding #include <tuple>
 
but the template isn't instantiated so any errors in that will not come up
 
guys ideone.com/J98htf it seems ok here
but why in your opinion and in the one of the compiler there is an error?
 
ideone seems to use gcc 6.3.0, so they don't have the issue
 
any alternative on how to implement that get code?
 
3:58 PM
well you can't since the compiler is buggy, you need to make compromises
for example avoiding variadics
 
or upgrading your compiler
 
variadics are my life :P
 
deal with it :P
 
there's always another way..
 
yes, that's getting a non buggy compiler
 
4:00 PM
yes I know.. but there are always different alternatives.. like implementing that in another way
 
if one guy paid you 1000000$ to make it work on that compiler would you not find another way?
I think I would
 
well, for starters I don't have your compiler, so I wouldn't
also focus on actual specification instead of the code
there's no need to use variadics if no one will pass more than 3 enum values, for example
 
the enums will be many, that's because I have to use variadics
 
that said, remove stuff from your code until it starts working, and then re-add them carefully
 
4:07 PM
it's just the get method, I've already done that
 
why isn't it inside the class?
 
because I like to separate the declaration from the definition and implementation
 
compiler doesn't care since it still has to see the implementation before the use
 
yes, but I care for the readability of the code :)
 
you're not the one in the position to negotiate
it's the compiler
 
4:23 PM
yep, that's right (unfortunately)... I hope to find another way without sacrifying readability
 
tough luck
 
sometimes the only option is to just suck it up and deal with withâ„¢
 
daily reminder that hacks can be removed from the code when they are no longer needed
 
4:46 PM
thanks anyway :)
 
 
5 hours later…
9:27 PM
How do I go about calculating (2^250)-2 ?
I know that with unsigned long long int i can store values up to 2^64 but that's not enough
 
nwp
use a bignum lib or some math trick to avoid doing the actual work
 
efficiency/speed isn't a problem, just how do I store it to then display it?
 
nwp
can you display it in binary?
 
It has to be displayed in decimal
Any relatively simple way without libraries?
 
nwp
you can write your own based on std::string if you don't mind writing throwaway code
 
9:34 PM
It's for a programming challenge, so writing good code doesn't matter at all
 
nwp
in that case just ask wolfram alpha
apparently the result is 1809251394333065553493296640760748560207343510400633813116524750123642650622
 
Apparently this is the official solution
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string add(string a, string b){
int digits = max(a.size(), b.size());
string result(digits, '0'); //result = "00000...0"

int carry = 0;
int posA = a.size() - 1;
int posB = b.size() - 1;
int posResult = max(a.size(), b.size()) - 1;

while(posA >= 0 || posB >= 0)
{
int digitA = (posA >= 0) ? (a[posA] - '0') : 0;
int digitB = (posB >= 0) ? (b[posB] - '0') : 0;

int sum = (digitA + digitB + carry);

result[posResult] = (char)((sum % 10) + '0');
 
nwp
so they went the std::string route, I would have expected that it was possible to do it a bit smarter
 

« first day (254 days earlier)      last day (2590 days later) »