« first day (297 days earlier)      last day (4665 days later) » 

12:00 AM
I'll try without the anonymous namespace.
Ah, there it is.
Bummer, that wasn't the culprit.
Wait the gdb start command, should stop at the start of main, right?
 
Never used that.
Try b main then run to see if it's a scope problem.
 
Hmm, I'm accessing a null pointer in some static initialization or something.
Trouble is, I don't remember doing any of that.
 
Using start works fine, the symbol is still here. Also the use of a temporary breakpoint suggests that start isn't doing anything special.
 
This is blowing up before main, there's no other possibility right? Static initializers somewhere?
 
Uh.
Dump a trace?
 
12:11 AM
How do I do that?
 
Assuming set pagination 0, bt
which I assume is short for backtrace
there's also bt full which may add more frame information but I don't use it much.
 
#0  0x00000001 in ?? ()
WTF is this?
This is the full trace.
 
info frame please?
 
Stack level 0, frame at 0x0:
 eip = 0x1; saved eip 0x1
 Outermost frame: unwinder did not report frame ID
 Arglist at unknown address.
 Locals at unknown address, Previous frame's sp in esp
Not very helpful, I think.
 
Nope.
There's a debug info problem here.
It could be that something bad happens during static initialization in a library with no debug symbols.
 
12:17 AM
That's ugly. I'm only linking to pthread and boost_system. Could this be because of the weird -shared flag I added the other day?
 
Oh god that flag
Might as well throw an -rdynamic at the linker, too.
 
You're serious?
 
Inasmuch as using -shared to cure your problem last time was a credible suggestion from CatPlusPlus.
So yes, try it.
(I think I just really wanted to say 'inasmuch'.)
 
Nah, it doesn't help.
Well, I'm going to sleep now, I'm really tired. Tomorrow I'll move this over to the sane environment I was using before (I fixed my AC adapter!), take -shared out and see if the problem persists.
 
I'll be honest but I don't think the findings of the debugger are reliable given that the compiling shouldn't use -shared :(.
So good night.
 
12:22 AM
Good night.
 
1:05 AM
hi @luc, hi @martino
its good morning for me , but good night to you
hi anybody,
 
 
6 hours later…
7:09 AM
morning
anyone here?
 
7:20 AM
hey baby
 
7:33 AM
hi
 
oh ghosh
anybody know how to overload operator! in C++?
I need it to return true or false based on a boolean variable
 
what is wrong with bool operator!() ?
 
yea but I'm not sure whether it should just return true when my boolean is true or opposite? I'm a bit confused
 
and what is wrong with a safe bool idiom?
 
I don't know what that is
 
7:36 AM
making operator bool() safe to use.
 
Well, think about how would behave if
 
i.e. if(my_object) will work, but not int i = my_object;
or ++my_object, etc.
 
would this make sense:
inline bool operator!()
	{
		if (isAlive()) return true;
		else return false;
	}
 
I'd write that return isAlive();
 
@TonyTheTiger Hey, maybe this will come in handy: adlertz.com/operators.pdf
 
7:39 AM
The semantics then are !some_object == some_object.isAlive(), is that what you want?
 
@LucDanton no I want to say, !some_object to mean that it is now no longer alive
 
return !isAlive(); then.
 
This makes sense since your classes yields the value of its isAlive() method, so operator!() return !isAlive()
 
Imagine you're writing an operator bool() instead: you'd want to return isAlive()
And since you're writing operator!, you stick ! in front.
FWIW !!some_object is called the double-bang idiom.
 
lol
but I think it has to change the IsAlive variable to false
not just return it to false... but change it
 
7:44 AM
Without context, it seems weird.
And in fact bool operator!() const would be expected here.
 
this is what I'm supposed to do
For the third action i.e. death of an animal, implement it by overloading
operator “!”. For example, when a pigeon dies (because of oldness or being
eaten by a hunter), it is written as “!pigeon”.
 
lol, this pigeon crap again.
 
I find that kinda weird, but yea
 
It seems like a terrible idea to me
Anyway, does it says which value should be returned ? maybe it doesn't matter
 
no it doesn't state anything about return values, just says what I posted here
 
7:48 AM
@TonyTheTiger If this is an assignment then do what it says. It's clearly an abuse of operator overloading and let's just live with that.
 
@TonyTheTiger Indeed, void operator!() seems applicable.
 
Is it possible to return void for operator!() ?
 
If it helps, imagine you're writing an EDSL using C++.
@kbok The only restrictions are on operator new (ditto delete) and more obviously, the conversion operators.
 
Ok.
 
7:51 AM
Another restriction of another kind is that operator= must be a member.
 
I can see why : int operator=(int& a, const int& b){ a = 0; }
 
Well, actually that sort of argument can be made for every instance of operator overloading.
e.g. int& operator+=(int& a, const int& b){ a = 0; return a; } is allowed.
The most common reason from members of the Standard Committee as to why operator= has to be a member is that it avoids some promotions of the left-hand side.
 
Some promotions? What do you mean ?
 
assume struct A {}; struct B { B(A); } A& operator=(A, int);
then B b; b = 0; would compile.
as if operator=(A(b), 0); were used for the second statement.
If you're wondering why this is allowed in the first place, this is because usually binary operators are symmetric.
Much as built-in types can be mixed in addition, e.g. short s; char c; s + c;, then it's fine to allow user-defined operators to do the same (following the C++ philosophy that everything can be used like int is)
operator= is however very much asymmetric. Don't ask me for the compound assignment operators!
 
I see.
Maybe the compound assignment operators are allowed to be declared outside the class so that they don't clutter the class declaration ?
 
8:03 AM
@kbok It's as good a guess as any IMO.
I forgot about operator overloading restrictions: operator->() must return a type that supports operator->()!
And this one must be a member too! operator()() too!
I guess operator->*() also has to be a member but I'm not checking tbh.
 
There's an operator->*() ?
I never messed with those weird animals
 
Yeah, the built-in one is used for pointer to members.
struct A { void f(); } *a; void (A::*pmf)() = &A::f; (a->*pmf)();
.* can't be overloaded though.
Turns out ->* doesn't have to be a member.
 
This is crazy, lol
Does it work for any pointer type ? like struct x { int* p; }; x* px; px->*p++; ?
Oh wait, this is a stupid question.
 
Now as stupid as you might think.
Pointers to members can point to data members, too.
struct X { int* p; } *x; int X::*pmf = &X::p; (x->*pmf)++;
 
u forgot int* x::*p = &x::p;
 
8:19 AM
Pointers to members take the form T C::* where T is the type of the member and C a class type.
Notice that T is a function type when the member is a function member.
And due to the syntax rules you get the parentheses: void (A::*)() for the first example.
And in fact void() const is a valid function type in that context.
struct A { void f() const; }; void (A::*pmf)() const = &A::f; compiles.
I apologize if that's a bit too much in one go, I guess I can be talkative about this stuff.
@sdt_intel Spain national body has also unanimously approved C++0x FDIS. #cpp #wg21
3
 
8:36 AM
w00t!
 
9:02 AM
Morning
 
Morning
 
9:29 AM
Man, C++0x just loves creating new syntax.
 
This is exactly why people hate PHP.
0
Q: How can we print a date onclick?

user885450This is a calendar script. Here when I click on a particular date then it will alert. But how can we print this date on onclick? <?php /* call calendar function */ function fncalendar($month,$year){ /* Outer Table for calendar */ $calendar = '<table cellpadding="0" cellspacing="0" class=...

 
FIX
// Wall of Code
 
10:35 AM
@LucDanton Yupee!
 
10:46 AM
Where can one see the FDIS vote results? Are they public?
 
@RMartinhoFernandes I have no idea how this works.
 
@LucDanton operator->* does not have to be a member; expressions like 5->*foo can be made to work. See my profile for a question on the subject.
 
3 hours ago, by Luc Danton
Turns out ->* doesn't have to be a member.
 
According to sbi's FAQ, the only ones that must be members are: =, [], ->, unary *, unary &, and ().
 
@RMartinhoFernandes That's odd, I got unary * to compile some time ago.
Ditto &.
 
10:52 AM
I'm too lazy to check the standard now.
 
@LucDanton Ah, sorry. Equally oddly, you can also define operator->* where the first operand is class type, and the second operand is a pointer to member of a different class type.
@LucDanton 13.5.1/1: A prefix unary operator shall be implemented by a non-static member function (9.3) with no parameters or a non-member function with one parameter.
 
Hmm, so the FAQ is not correct in this aspect.
 
11:17 AM
room topic changed to Lounge<C++>: Bunga Bunga partay! [c++]
 
@MarcGravell If you're the moderator, a Bunga Bunga party is more moderate than what?
 
AFAIK, my only change was to add a C++ tag. I believe the Bunga Bunga partay was the existing room description.
 
11:25 AM
I mean, if the purpose of a moderator is to make things more moderate. Bunga bunga party sounds pretty extreme.
Oh.
 
don't ask me what it means
 
Yes, it was. But you didn't change it.
Oh wait, you did.
I had to refresh my browser to see it.
 
did I?
what was it before?
 
You added a tag.
Is this a magical tag thingy that associates the room with the questions on the site?
 
right; that's exactly what I thought I was doing ;p
It will be, in time
 
11:26 AM
Do we need to remember to put the tag on the room topic?
 
no - separate field in the UI
 
oh....
 
Ah, I see.
 
the idea being: if we want to show rooms, we can bring those on-topic to a question to the top
for SE generally it isn't as much of a problem, but on SO... it kinda is
 
Yeah. Good deal. Now we just need a way to keep PHP questions out of this room.
 
11:29 AM
I suppose the PHP room will have a similar anointment.
 
We'll see what that does to the entropy that seems to bring those guys here.
 
if nothing else, it is one more way to make it obvious where they should be headed
 
I thought we agreed we're not really interested in C++ question dumps either. :P
 
If it turns out to be evil, we can take it out.
:P
 
Hey, another "plz grab a book" question
0
Q: Using multiple .cpp files in c++ program?

TheCompBoyI recently moved from Java for C++ but now when am writing my application am not intrested in writing everything of the code in the main function i want in main function to call another function but this other function is in another .cpp file. Let me explain better if you wouldnt understand: I h...

 
11:40 AM
I had already posted a comment to the effect.
Now to close-vote.
Oh, when will we have the "General Reference" close reason?
 
I could use a "shitty question" one.
 
Lol, what

> You need a linker. [Here's a previous question about which to use][1]. <!-- No, this is NOT A COMMENT. For FUCK'S SAKE Stack Overflow. --> [1]: stackoverflow.com/questions/3925409/linker-for-clang – Tomalak Geret'kal 31 secs ago
 
Eh, give him a break. 15 years old, still building his research skills.
 
What the heck?
 
12:18 PM
@RMartinhoFernandes Hmm, it doesn't seem to account for accumulation of upvotes on old questions that continue to see high traffic. That should decrease the correlation. But interesting analysis anyway.
 
What is the name of operator->, using only alphanumeric characters? :)
 
It's the class member access operator.
 
@RMartinhoFernandes Wouldn't that be . ?
 
They're both.
 
Ok.
 
12:29 PM
The standard doesn't give them different names.
 
i always call it the pointer oper@tor
 
But it can be used on non-pointer types.
Case in point: std::unique_ptr<int>. Yes, I'm cheating.
 
"operator-> shall be a non-static member function taking no parameters. It implements the class member access syntax that uses ->."
So it's the class member access syntax that uses the -> operator
 
Hah! You used non-alphanumeric characters.
 
so good thing I remembered the URL to chat :) They took the link off of the main SO page
 
12:33 PM
(And the name of the operator is not "some syntax that uses the operator")
 
@CodeMonkey dude I was just writing that
 
@hexa ah
 
I did not remember tho'. I typed chat and waited for my browser's suggestions
 
"operator minus greater"
the GCC source often refers to it as the arrow.
 
I've seen arrow a lot too
 
12:36 PM
Until someone comes up with a better name, I'm gonna call operator-> "The Delegator", featuring Arnold Schwarzenegger.
 
INTERCAL would call it "worm, right-angle".
I'm disappointed. "right-angle" is not a particularly silly name for >.
 
hi
 
What's up?
 
12:52 PM
Okay, I wrote a header delegator with the following contents:
#ifndef DELEGATOR_TYPE
#define DELEGATOR_TYPE T
#endif

DELEGATOR_TYPE* operator->()
{
return &**this;
}

const DELEGATOR_TYPE* operator->() const
{
return &**this;
}

#undef DELEGATOR_TYPE
Is that smart or stupid? :)
 
What's this for?
Save some typing?
 
that would really piss me off if it was in production code
 
First I wanted to do it with inheritance, but it didn't work, because there was no operator* in the base, of course.
 
It's 8 lines. Two if it were me.
 
12:54 PM
It's more customary to make such code a macro, not an entire separate header.
 
If I see #include <blah> in the middle of a class, I freak out.
 
Morning (for me at least) everybody.
 
Given:

void func(const std::string& s) { cout << s << endl; }

Why func("string literal"); works?
 
Gmorning.
 
So I read an article today that .NET is dying
not sure if I believe it or not
 
12:56 PM
@CodeMonkey Every technology is dying. I doubt C++ will be around in 1000 years.
2
 
i heard that as well ( ^^ ).
 
@hexa Compiler error.
 
@hexa You are using a Microsoft Compiler with an evil "extension".
 
it's "dying" because Microsoft have noticed that it can't solve every problem and it's no longer the wonder child
 
Well, the argument is that Microsoft does not market it enough
 
12:56 PM
rofl
 
and let's Apple walk all over it
 
actually It was const i think
 
Microsoft markets .NET a hell of a lot more than C++
 
@CodeMonkey With Objective C or what? :)
 
and last I checked, Apple does not compete in the "Applications for Windows Desktop, Xbox 360, or Windows Phone 7" markets
 
12:57 PM
@RMartinhoFernandes You're probably right, I'll just copy/paste the operator-> code whenever I need it.
 
Well, the article said that .NET is more than just the framework, it's the platform Microsoft is selling and Apple got huge wins because of the ads it showed. The article went on to say that Microsoft invests more in marketing than developing the Framework.
 
1 min ago, by Code Monkey
Well, the argument is that Microsoft does not market it enough
Is there a contradiction somewhere?
 
tell that to the billions of dollars in profit WinDiv made this year
 
You can also implement operator-> by CRTP with a custom iterator base class, which may be derived from and supplant std::iterator
 
let me find the article...
 
12:58 PM
@hexa It's fine to pass temporary objects by const references
 
I was just thinking why not just use CRTP
 
The char* constructor is used to create a temporary which is deleted after the function call ends
 

« first day (297 days earlier)      last day (4665 days later) »