« first day (459 days earlier)      last day (4472 days later) » 

12:00 AM
welcome back :)
 
:D
doing my final project and a class on game engine architecture and a class about specialized datasystems, all c++ classes.
 
oh nice :)
sounds interesting
 
the specialized datasystems one is very cool, we are learning about creating query systems that can take an image as the query and return similar images
 
@all , Oh sorry for being off. I was stuck somewhere between parallel universes
 
how was it there?
 
12:06 AM
It was uber fantastic, Ritchie told me some secrets about c++. I wish only if I could tell you...
 
btw
who linked to Problem 18/67 of Project Euler?
 
It was me, I gave a task to @Marthino to solve it
however I don't know what happened with him
 
I can solve it pretty easy
 
he didn't reply
don't bother with it
 
what, you already solved it?
 
12:09 AM
:) it took me only 3 mins
 
did you brute force it?
 
pick a problem from 200 to 300 and lets compete who fster solve it
 
no thanks
I just found this specific problem more interesting
 
kinda :)
yeah, we don't need to waste our time doing something we already know
Arent' we all, just another
 
Help me procrastinate.
 
12:16 AM
This song is very inspirational one.
 
12:35 AM
SOPA ruined my thesis.
 
What do you mean Xaade?
 
@DzekTrek There's someone complaining that the wiki blackout will ruin their research on their thesis, since they'll lose a value shotgun resource saving time.
 
just dl wiki
:P
think it's only 16GB compressed
iirc
 
Haha :) Very true @ÓlafurWaage , @Xaade
 
TIL also that you can select wiki pages and make a book
 
12:39 AM
@ÓlafurWaage only 16 GB
No big deal.
Just two nights of download.
 
what puny dl rates
:D
 
:D
Where are you from Xaade?
 
@ÓlafurWaage Not everyone has a T1 connection.
I could probably dl 16 Gigs overnight, but not in less than 5 hours.
 
T1 is only 2mbits i think
 
@DzekTrek I'm from a place that's not the place I'm not from.
 
12:41 AM
Interesting, sounds like a puzzle to me. :P
 
@ÓlafurWaage but it's dedicated. Precious cable connection with 6, hardly has 6 for more than the first few megs of download.
@DzekTrek It says nothing.
All I can say is not what I can't say.
same pattern.
 
They have a fibre to the box next to my house, so I have theoretical 50Mbits :S But a crappy dl cap.
 
@ÓlafurWaage You misunderstand the difference between dedicated and shared.
 
No, I know the difference. I'm just ranting about my current state of internet :)
 
12:44 AM
You'll never see 50, because you have to share with a bottleneck further away.
 
It's also 50Mbits. So it's 1024 * 50 / 8
And I have gotten that speed a few times, even from foreign servers.
And T1 is just for you, all the way through the system.
 
I "have 12" but I never really have 12.... just for the first few seconds, then 6 for a few meg, then 3 for the whole download.
Then, if everyone's online at once, it could drop to below DSL.
And that's standard for everywhere.
 
hehe
<-- Used to work as a teacher for our local isp tech support
 
I have 30
but in reality, it tends to go up to 35
 
So I've had my fair share of dl stuff
 
12:48 AM
:D
I have 2 mbs, but that's too way much for me, 'cause I don't dwl pretty much anything from the net, apart for some source codes
 
What ticks me off, instead of sharing actual bandwidth, they share a fixed value, that decreases exponentially with active population. Let's say you have 50 on a line, and 5 people are on that line, they give each 12 for short bursts and 6 if one person's on. Then 5 if two are on, and 1 if all five are one. There's far more than 5, but with all five on they get less than dsl connection. The rest of the bandwidth is just sitting there.
 
while speaking about source code, do you happen to know some good site which provides source code? Something like hackchina.com?
 
You on cable Xaade?
 
They want to ensure they can offer that 12 for short bursts. So if all are on they demote them to 1 each, so that they can offer 12 at time-sharing.
@ÓlafurWaage yeah.
 
Ya, we only have DSL here
 
12:51 AM
They should just offer everyone 10 each.
 
so I'm only familiar with that
 
All the time.
Instead of worrying that people can get 12 for short bursts so they appear to be fast if you're not downloading a large file.
It's stupid.... It's just 2 more Mbs that you never really have, instead of 10 that you can always have.
Then if one person is on, give them the full 50.
@ÓlafurWaage DSL is different, it's rationed by distance.
Cable is rationed by time-share.
With DSL, people close get super fast speeds, and people far away always have slow speeds.
 
I've never experienced this slowdown on my dsl. It's always been pretty constant. DSL is rationed by distance due to the technical limits of it (6km cap)
 
With Cable, they don't have that problem, so they ration with stupidity rather than distance.
 
Hehe
My neighborhood had DSL distance issues, so they installed fibre in the local boxes
Now my life is awesome. I feel like I'm an infomercial
 
12:54 AM
@ÓlafurWaage DSL is physically self-rationing, due to deterioration of data over distance, and the need for amps.
 
Yup
We also have laws there that guarantee every full year home to have at least 256kbits of speed
So houses out in nowhere need to have DSL or something else
Some farms have WiMAX
 
@ÓlafurWaage that does very little.
Like guaranteeing everyone to have a $1 of gas during a hurricane.
 
Hehe, but that actually cost the ISP a lot, since they had installed amplifiers to allow farms to have ISDN, but those are digital amps, and they have to be dug out to replace the line.
 
@ÓlafurWaage I've often found that laws that guarantee everyone something, lower the bar for everyone on everything.
 
So 1 farmer can have 256kbits and pay a tiny monthly fee for it
The american army was stationed here a few years ago. They had a limit of 56k connections back in the day. So all the houses there were fitted to allow for that.
 
12:58 AM
@ÓlafurWaage And all the city folk pay double what they would have.
So that a farmer doesn't have to buy expensive satellite.
 
Hehe possibly ya. We also pay A LOT since we're on an island, and those sea cables aren't cheap
well, sleep time, l8r
 
Morning.
 
1:19 AM
Evening.
 
w
 
 
2 hours later…
3:45 AM
Three characters? I hate missing subject changes in this room.
 
4:19 AM
good evening everyone.
i need little bit of help understanding behavior of virtual function..
Could anyone spare some time here? please.
 
user406009
Don't ask to ask, just ask.
 
just didnt want to be rude. Okay
Suppose i have two classes looking like this

class Base{
private:
int a;
public:
virtual void doSomething(); //
}


class Derieved: public Base{
private:
int b;
public:
virtual void doSomething(); //
}
int main(){
Base b = new Base();
Derieved d = new Derieved();

d-> doSomething();
b-> doSomething();

(d)(b)->doSomething();
}
pardon my mistake in (d)(b)->doSomething(); I am wrong about type casting base pointer to a derieved pointer type. I forgot the syntax here.
 
user406009
Are those intended to be pointers?
Make sure to click the 'fixed font' botton on the right of send when you are posting code.
 
Okay.. will do. from next time
yes, they are intended to be pointers
 
user406009
The sytax for type conversions is usually (Type)value. (There are other ways to convert, but you can look up C++ style casting).
 
4:27 AM
i want to understand the process at runtime of selecting the correct method which has to be called by the three statements in main()..
 
user406009
The statement selected at runtime is the class instance created with new. Wait a sec, I am posting your thing on ideone.
 
so would it be correct if i write (D)b->doSomething();
ideone?? what is that..
 
Xeo
What, the robot still here? @RMartinhoFernandes <pling>
 
write**
 
user406009
There we go, perfect.
 
user406009
 
I am looking at it.
 
user406009
And no, that would be incorrect, (Derived*)b is a cast from a Base to a derived class.
 
user406009
You can only correctly cast from a Derived to a Base class.
 
Okay...
I want to know why ((Base*)d)->doSomething(); printed "Derieved".
 
user406009
Virtual functions depend on which type is used at construction.
 
4:33 AM
at construction.. which is derived... so it doesnt not look at the Type casting i did?
 
user406009
No
 
can i keep asking more questions?
i have few more doubts and i want to understand those too?
I want to know what does Object Construction mean?
i will come back to this Virtual Method question again after getting this doubt solved
 
user406009
Object construction is when the constructor is entered( I think, haven't really read the standard).
 
Okay.. So what does it include..
 
user406009
So when you do Foo *f = new foo() an object is created at the new foo statement.
 
4:35 AM
Memory allocation for that object? and initilalization of the data members of that object.
by the default constructor
 
user406009
Or when you do Foo f(blahArg); an object is created then too.
 
passing blahArg as an argument to the constructor for Foo.
correct?
 
user406009
Yeah.
 
user406009
As to your previous question: @Leoheart This is the order. 1. Memory is allocated. 2. The base class constructed
 
wait? But isnt base class constructor called before the memory allocation of derieved object
 
user406009
4:37 AM
3.Your members are constructed. 4. Your object is constructed.
 
user406009
All the memory allocations are in one go. The size of a derived class = own members + size of base class.
 
user406009
So the compiler can just do one allocation.
 
Okay.
got it.
Now lets come back to my first question.
 
user406009
As soon as you get to step 4, your constructor, the compiler sets some magic numbers that tells which function to use.
 
which functions to use for what?
 
user406009
4:40 AM
For virtual function calls.
 
this is what i need to totally understand today.
lets come back to first question.
 
user406009
There is a "hidden member" inside classes with virtual functions that stores which function to call when a virtual function call is requested.
 
and then reach here again.
are you talking about virtual table pointer?
 
user406009
Yeah.
 
Okay.. wait please
Can we start over from first step.. correct me and please explain where i get stuck
so
at run time, vptr is created and vtable is created for both base and derived
i want to understand how wil it look like.
 
user406009
4:44 AM
Have you worked with function pointers?
 
yes
but not like too much..
i want to understand how vtable looks like?
 
user406009
It's an array of function pointers.
 
is it an array or map?
 
user406009
I would assume an array, the compiler knows all names of functions, so it can turn those names into integers easily.
 
because each entry of an array when accessed should be able to tell me, which function should be called for this particular function pointer
 
user406009
4:47 AM
Yeah.
 
so i guess you are assuming that for an entry i can assume that index correponds to function pointer, storing the location of virtual function which has to be called.. for example 0th entry corresponds to location 1st virtual function in class and so on
Correct?
 
user406009
Something like that.
 
please read again. i made some changes
looks correct?
now lets say in our case, we have vtable looks like this
vtable[0];
where value of this entry should correspond to address of correct virtual function which has to be called?
correct?
 
user406009
Yes.
 
Okay...
 
user406009
4:52 AM
Here is an example of a vtable.
 
user406009
 
user406009
In C of course.
 
Now here comes my question, which i always wanted to know... how to decide the value at this index of vtable
 
user406009
Probably an internal map in the compiler.
 
user406009
name of function to function data structure, which contains the internal id somewhere.
 
4:54 AM
that is what i wanna know.
how is this mapping defined and how does compiler come to know what value it has to put in that index of vtable
give me a minute to read your code
 
user406009
Both those questions are compiler dependent. I have no idea how it would internally be implemented.
 
i understood your code. Seems an example of virtual function.
but i want to know how does compiler decide which function to call
Thanks a lot though for writing the example.
so now.. for this

((Base*)d)->doSomething();
 
By routing the call through the table, that's the whole point of the thing.
 
yes. Cat Plus
thats the question, what does that routing do
for example. have a look here ideone.com/Xc4bU
 
Indirection.
 
4:58 AM
i need to understand that indirection.
 
Instead of calling function at hardcoded address, the address is loaded from memory.
 
yes and how does it know which function to be called from memory.
 
Each object carries a pointer to its class vtable, and for the entire hierarchy the layout of the vtable is the same.
 
yes.
that means virtual functions have same offset in vtable?
Please give me a minute.
 
Classes can be split into two parts — a structure with data, and a bunch of free functions that take this structure as an argument.
 
5:05 AM
Finally my code compiled. phewww
i am not good as you guys. sorry for taking time
 
Eh, I don't really have time. The point is, having a table with function pointers lets you use another implementation at runtime, as opposed to static dispatch where all the function addresses are hardcoded into call sites.
 
i know that totally.
 
Wikipedia's blackout is apparently just some JS code.
 
i just need to completely understand "how".
Thankis for spending time on me Cat plus.
i need to understand how that ouput came. I know most of the stuff, but when this vtable comes into picture, i need your help there.
Ethan... there?
:(
I am almost exactly there, where i started.
:(
Okay then. i will move on from here to read about it from books.
 
user406009
@Pubby It's a very good "half blackout" though. The people who don't know about SOPA don't know about JS and will read the thing.
 
user406009
5:13 AM
Those that know what is going on can cruise by.
 
user406009
They need to get better artists though. The whole black on white blackout page is really ugly.
 
5:27 AM
Hi everyone.
@Xeo: I was nopping.
 
Xeo
Oh, welcome back then. And join in one the fun!
 
FWIW, your last snippet compiles fine on GCC 4.7.
$  \MinGW-4.7\bin\g++ -Wall -Wextra -Werror -pedantic-errors -std=c++11 a.cpp
a.cpp:58:7: error: unused parameter 'x' [-Werror=unused-parameter]
cc1plus.exe: all warnings being treated as errors

$
Well, there's an error there, but not relevant.
Oh wait, it's the output that is wrong, not the compilation.
 
Xeo
Still wrong output for the overloaded cases?
(Boom and Frob)
 
$  \MinGW-4.7\bin\g++ -Wall -Wextra -Werror -pedantic-errors -std=c++11 a.cpp
$  ./a
Foo(const int &):  0
Foo(int &):        1
Bar(const int &):  1
Bar(int &):        0
Zap(const int &):  0
Zap(int&):         0
Wazz(const int &): 1
Wazz(int &):       0
Frob(const int &): 1
Frob(int &):       1
Blip(const int &): 1
Blip(int &):       1
Boom(const int &): 1
Boom(int&):        0
$
Hmm.
 
Xeo
Correct output
 
5:41 AM
There's a lot of misses there.
@Xeo Blip(int &): 1?
 
Xeo
yes
 
Am I missing something then?
Wasn't it supposed to test true only if the parameter was a int const&?
 
Xeo
GCC 4.5.1 would report 0 for Frob and Boom
@RMartinhoFernandes No, if it was callable with those exact parameters that are in parens
Aka it got int & in the signature, and not int
 
Oh, I'm misinterpreting the output. Nevermind :S
 
Xeo
or somesuch stuff
I really don't know why the OP wants that
but it's fun to tinker with
 
5:43 AM
I'm struggling to find an use for it.
But that never stopped us.
 
Xeo
I have absolutely no idea why Pling(const int &) reports 1.
It makes sense, but it shouldn't do that.
 
std::endl all over makes you look like amateurs ;)
If all that template machinery wasn't around...
 
Xeo
mimimi, I just copied @Ben's code, who copied it from @Kerrek. :P
 
> a.cpp:87:52: error: cannot convert 'int (Pling::*)(const int&, char)' to 'int (Pling::*)(const int&)' in initialization
Given int (Pling::*pmf)(int const&) = &Pling::operator();
 
Xeo
Ohoo?
Ah
 
5:48 AM
I can't fathom why it would pass.
 
Xeo
Well, why does it work in the code then?
I need a template backtrace..
D: my static_asserts in sfinae aren't being triggered.. damn unevaluated context!
 
Xeo
sfinae is killing my attempts to create a backtrace oô
 
Hmm.
template <typename C, typename... A>
void f(decltype(std::declval<C>()(std::declval<A>()...)) (C::*pmf)(A...));

  // ...
  f<Pling, int const &>(&Pling::operator());
This compiles.
 
Xeo
that's seriously strange
 
5:55 AM
Because the rest of the arguments are deduced!
 
Xeo
Omg!
Seriously?
 
It's f<Pling, int const &/*, deduce char */>(&Pling::operator());
Makes perfect sense.
 
Xeo
holy!
Hi Ben!
 
TIL: variadic templates will deduce lots of stuff you may not want.
 
hi Xeo.
 
Xeo
5:57 AM
Just read the last few messages
 
Why are the chatroom links no longer showing up on SO?
 
Xeo
TL;DR: what @RMartinhoFernandes said. It's deduced.
 
I never understood the criterion, but the links to chat only show up at times.
 
Xeo
@RMartinhoFernandes It's fixable with a second template parameter pack and a sizeof...(Brgs) != sizeof...(FArgs) something test
 
@Xeo Add more indirection!
 
Xeo
5:59 AM
I think
 

« first day (459 days earlier)      last day (4472 days later) »