« first day (361 days earlier)      last day (4604 days later) » 

5:00 PM
hmm
well, it does bother me that my applications aren't Unicode-aware, at all, really
 
Als
ohla
 
but since I don't make any applications worth considering, it's arguably a moot point
 
Als
@RMartinhoFernandes: Hello Sire
 
I need to GTFO this place and go to my nice warm bed
 
Als
5:01 PM
@RMartinhoFernandes: You seem to be in an make this place cleaner trip I noticed :)
 
bb
 
@Als What do you mean?
 
Als
@RMartinhoFernandes: Lots of edits to answers, making everything spick and span
:
:)
 
Since I got to 20k, I don't feel like racing to an answer so much.
So I mostly edit stuff.
 
Als
@RMartinhoFernandes: Its nice though and I meant it as an compliment.
 
5:05 PM
 
Als
Especially, You don't act like a jerk while doing so
 
Bah, problem with niche games, multiplayer is 100 players and you can't get into any game.
 
user457812
@AlfPSteinbach Suddenly it makes sense.
 
In order not to offend @DeadMG I'll post this as a humble link.
 
5:11 PM
53
Q: Can I use my powers for good?

FloundererI hesitate to ask this question, but I read a lot of the career advice from mathOverflow and math.stackexchange, and I couldn't find anything similar. Four years after the PhD, I am pretty sure that I am going to leave academia soon. I do enjoy teaching and research, but the alpha-maleness, mas...

Awesome title.
 
Howdy
 
Already a vote to close my question. Ugh.
 
@StackedCrooked Your "hooking" thing is supposed to be static, or dynamic?
Dynamic would probably require some more reflection.
 
As @sbi mentioned before, I should use std:copy instead of memcpy, is there an equal replacement for memset?
 
sbi
5:15 PM
@ManofOneWay std::fill()
 
sbi
@RMartinhoFernandes :b
 
Als
@sbi: Hola
 
in which library?
 
3
Q: Function hooking in C++?

StackedCrookedWith "hooking" I mean the ability to non-intrusively override the behavior of a function. Some examples: Print a log message before and/or after the function body. Wrap the function body in a try catch body. Measure duration of a function etc... I have seen different implementations in variou...

I think your question is being unjustly closed.
 
5:16 PM
@RMartinhoFernandes I mostly care about a solution that requires very few manual work. I don't really care about static/dynamic.
@RMartinhoFernandes This is so SO :(
 
@StackedCrooked Wait, but you should. What I mean by static vs dynamic is a matter of the hooks being set in stone upon compilation, or being interchangeable at runtime.
 
Als
@RMartinhoFernandes: Anything that calls for extensive discussions in SO gets closed
 
"Are there any reasons that prevent this from being made possible?"
 
Als
probably, they feel its better on Programmer SE it seems.
 
Seems a pretty straightforward question.
I don't know the answer, but I don't vote to close based on that,.
"What are some recommended techniques or libraries to implement this in a C++ program?"
 
Als
5:18 PM
I didn't vote to close, but that is how folks think in here.
 
Seems like a decent question too.
 
sbi
@Als Hi.
 
Basically, "Since there's no language support, how could I implement this?"
Maybe some people have a filter for the word "recommended".
And I am the robot.
 
Als
@sbi: How are you doing? I see the Meta thread keeps you busy quite a lot..probably I am to blame...
 
Is it possible to define own operator names?
 
5:22 PM
No.
 
You can define user-defined literal operators in C++11, but that's not exactly the same thing.
 
Okey, how does it work? I would like to define the dot operator between two vectors, so that I can write , v1 dot v2
 
That you can't do.
 
when a container expands , iterator gets invalidated which was pointing to some element?
 
5:23 PM
maybe it's ugly and not according to C++ standard?
Too bad
 
@ManofOneWay In the past I just went with dot(v1, v2) and cross(v1, v2).
 
Do you have any other suggestion besides v1.dot(v2);
okey
then dot should be defined in the vector class at least
 
You can easily make it a nonmember function.
 
how do I make it a no-member function?
 
A function that isn't a member of a class.
 
5:25 PM
static?
 
Also known as a free function.
Lemme show an example.
 
but could I have it inside the Vector class ?
So it's not instance related i.e. class method?
Sure
 
sbi
@Als Not only that. I spend a lot of time today on meta and meta.P.SE.
 
What exactly is a static member function?
Something that is not instance-related?
 
5:27 PM
@ManofOneWay Yes.
 
Great!
 
Als
@sbi: hmm..I am pretty much disappointed by the happenings on that thread.
 
It's a function that is a member of a class, but has no instance associated.
You need to call it as foo::qux().
 
sbi
@Als Forget that Won't guy. Tim has said he's at it, that counts.
 
Yes, that's exactly what I want
 
5:28 PM
@ManofOneWay Not in C++, but it is allowed in some other languages (ML and most of its descendants, for one family of examples).
 
In Haskell you can make operators out of pretty much anything.
Even type constructors.
 
Als
@sbi: The mods, themselves don't seem to be in sync & As I see won't guy is the one whom replied me when I had flagged.
 
@sbi In case you don't know Won't is Will.
 
sbi
@RMartinhoFernandes Shrug.
 
Now another problem arises
inline float
static dot(Vec2 &v1, Vec2 &v2)
{
float r;
r = v1.y * v2.y + v1.x * v1.x;
return r;
}
Where do I add the Vec2 ::
 
5:31 PM
As usual, before the function name. And you missed the return type.
 
inline float Vec2::dot(const Vec2& v1, const Vec2& v2)
 
no, the return type is above
 
Sorry, not used to that style :)
 
'static' can only be inside the class definition
error
:(
 
Then get rid of the static outside of the class. It means something else entirely there, anyway. (internal linkage)
 
5:33 PM
Just remove it, it's fine.
I'm having a terrible headache.
 
too much programming?
 
@FredOverflow Decide!
 
dereferencing a iterator which has been erased doesn't yields undef. behavior in std::list?
 
@FredOverflow Did you see my 8-queens solution?
 
@RMartinhoFernandes only shortly, accidentally clicked the wrong bookmark at work :) repost link again, please
 
5:34 PM
declaration 1) or 2),
1) inline float static dot(Vec2 &v1, Vec2 &v2);
2) static inline float dot(Vec2 &v1, Vec2 &v2);
 
@ManofOneWay You really should have references to const as parameters if they are input parameters that you don't intend to modify. Otherwise, clients won't be able to pass in rvalues.
 
@FredOverflow yes that's right, thanks
 
i.e. dot(u + v, t) won't work.
 
so, how should my declaration look like?
where to put the static?
 
5:36 PM
How large is Vec2? What members does it have?
 
float x,y
 
Then I would just pass them by value.
static inline float dot(Vec2 v1, Vec2 v2);
IMHO not worth the extra indirection if all you have is two floats.
@MrAnubis erased or invalidated?
20
Q: Iterator invalidation rules

Tomalak Geret'kalWhat are the iterator invalidation rules for C++ containers? Preferably in a summary list format. (Note: This is meant to be an entry to Stack Overflow's C++ FAQ. If you want to critique the idea of providing an FAQ in this form, then the posting on meta that started all this would be the plac...

 
@FredOverflow @RMartinhoFernandes ideone.com/WxUgP
That's how it looks right now
 
@FredOverflow erased , already reading this post :)
 
Make the operators const.
And operator<< is not very orthodox.
 
5:39 PM
Vec2(const float x,const float y); ?
 
@ManofOneWay No, I mean Vec2 operator - () const;
As it is, with operator<< you'd need to do v << std::cout to output, which is a bit weird.
 
Why do == and != take different parameters, one const and the other non const?
 
Good question =)
typo
 
You can't have operator<< as a member function, it needs to be a free function taking two arguments, a stream and an object of your class.
 
29
A: Operator overloading

sbiCommon operators to overload Most of the work in overloading operators is boiler-plate code. That is little wonder, since operators are merely syntactic sugar, their actual work could be done by (and often is forwarded to) plain functions. But it is important that you get this boiler-plate code ...

 
5:41 PM
std::ostream &
Vec2 :: operator << (std::ostream &s)
{
return s << this->x << ' ' << this->y;
}
this doesn't work then?
 
No, because the calling syntax would be myobject << std::cout; which would be very weird.
 
Doesn't work as you expect, no.
 
ah that's true
 
Wait, you can.
Silly me.
Nevermind.
 
So does it have to be outside the class?
 
5:43 PM
lol
 
or could it be a static?
 
Well, you could if you really wanted to... myobject2 << (myobject1 << std::cout);.
 
@RMartinhoFernandes @FredOverflow What do you guys think is better? Have operators defined the way @ManofOneWay does or have free standing specializations of std::plus, std::minus etc ...?
 
@ManofOneWay Outside.
 
@ManofOneWay What would you gain by making it static?
 
5:43 PM
So that I know it's a function for that Vec2 class only
 
Won't the parameters give that away?
:)
 
@Praetorian The standard way is to have += as a member and + as a free function.
 
Sure, but then it will be in the same file
if it's static
 
@Praetorian If you implement operator+, you get std::plus for free.
@ManofOneWay You can put it in the same file.
Files and classes are orthogonal.
 
@ManofOneWay In C++, we prefer free functions over member functions, because free functions improve encapsulation.
6
Q: How Non-Member Functions Improve Encapsulation

AppuI read Scott Meyers article on the subject and quite confused about what he is talking about. I have 3 questions here. Question 1 To explain in detail, assume I am writing a simple vector<T> class with methods like push_back, insert and operator []. If I follow mayers algorithm, I would ...

 
5:48 PM
@RMartinhoFernandes Yes, of course; I was just wondering if one is considered more idiomatic than the other
 
@Praetorian Obviously, implementing operator+ is preferred, because you get both. If you only specialize std::plus (is that allowed?) you don't get operator+.
 
AFAIK it is ok to create your own template specializations within the std namespace
 
Not all templates can be explicitly specialized.
 
and even if you did it within your class' namespace ADL should find it
 
std::plus isn't commonly used ADL-enabled.
Wait, there's no ADL for classes.
But now that's a good question. What standard templates can you specialize?
 
Als
5:53 PM
@sbi: "That someone is already found.You were told to mail the team. If I was you, however, I'd wait for what Tim comes up with." I agree with you on waiting for what Tim comes up with.
 
Anything that isn't explicitly forbidden, or only those explicitly allowed?
 
Als
@sbi: But I did not understand What was I asked to mail?
 
Also, Boost.Operators.
 
Dammit, my dad thinks software developers get the same salary as plumbers. He wants me to become a doctor like him. :(
 
@RMartinhoFernandes Wait, I lost you. Are you saying if I write namespace foo { template struct plus<MyType> { /* .. */ }; } it won't be found by ADL?
 
5:54 PM
ADL only works for functions (it's argument -dependent lookup after all)
 
Als
@IntermediateHacker: If its true you should become a doctor
 
sbi
@Als You mail them the actual data (when, what) and your suspicion that it is a revenge downvote spree.
 
Als
though some doctors I know dont wnough enough as Plumbers
 
@RMartinhoFernandes Yeah but all plus<T> contains is operator(), doesn't that count as a function?
 
And ADL doesn't work if you write std::plus. That's the plus from the std namespace, no way out.
 
Als
5:55 PM
@sbi: Where was I told of doing that?
 
@Als is it true? i doubt it.
 
@Praetorian But you need to create the object first: std::plus<T>().
 
sbi
@Als By Jeff?
 
Even if it was, i'd still never become a doc
 
sbi
And didn't that mod not say the same?
 
5:56 PM
non-member function = free function?
 
Als
@sbi: You mean the team@stackoverflow thing
 
swap is commonly used ADL-enable, because people write things like:
{
    using std::swap;
    swap(x,y);
}
 
sbi
@Als Yeah, of course, that's what we're talking about, no?
 
Als
@sbi: I should wait for what Tim comes back with.Just the Wont guy pissed me a bit.
 
5:57 PM
std::swap(x,y) would always call the version from std.
 
sbi
@Als Yeah. I believe I already said so. :)
 
swap(x,y) would fail if there was no swap found through ADL.
The using std::swap makes it so it falls back to std.
 
i hate docs.
 
@RMartinhoFernandes Yes, but in case of swap I think all algortihms from the standard library call just swap(x,y), not std::swap(x,y), specifically to enable ADL
 
Right.
But they always call std::plus<T>(), so it wouldn't work even if it worked for classes.
 
Als
5:58 PM
@sbi: Yes. I'll wait for Tim's reply. Just that the Wont guy pissed me with his antics of trying to wash off the whole thing, as A-Holes will be A-Holes forget policy.
 
I'm gonna have to try out plus, using std::accumulate should be a good test right?
 
Als
@IntermediateHacker: Do what you like, You wont be a good doctor if you dont like it, Same applies to being a programmer.
 

« first day (361 days earlier)      last day (4604 days later) »