« first day (264 days earlier)      last day (4699 days later) » 

12:07 AM
@MartinhoFernandes I bet he did it out of spite... but it'll give phresnel a chance to earn that badge :-)
 
@KerrekSB Oh hey. Sorry about 'standing you up' earlier -- I was cooking.
 
Man, I envy anyone that can cook.
 
@LucDanton No worries!
What were we even discussing... emplace-iterators?
 
Yes
 
I was cleaning my oven. Wiht MrMuscle -- it's highly corrosive, works like magic and tons of fun.
Also managed to corrode my hands.
So... does it not make sense to have an emplacing version of an insert iterator?
 
12:09 AM
Not sure if you figured it out but the only thing that it would enable is in the case that a type T is constructible from U but where U is not convertible to T: no non-explicit constructors for T and no non-explicit conversion operator for U
 
The usual insert iterator would make a copy, wouldn't it?
 
So assume struct U {}; struct T { explicit T(U) {} };
@KerrekSB No, the iterators forward
 
Oh OK... but so does insert, and yet we also have emplace
 
Then *std::back_inserter(container) = U{}; is ill-formed
You have to do *std::back_inserter(container) = T { U{} };
That's the one thing std::back_emplacer would allow.
 
Your container is of type <T> I assume?
 
12:13 AM
Correct
Although
One could imagine an overload for operator= that would accept a tuple and forward it's elements to container::emplace
 
If I had vector<T> v;, and struct T { T(X x, Y y, Z z); ... };... never mind default constructibility for now... then I could say copy(w.begin(), w.end(), back_inserter<T>(v));. S far so good.
But suppose I have functions X getX() etc.
 
i.e. *std::back_emplacer(container) = std::forward_as_tuple(42, 0.) would be doing container.emplace_back(42, 0.)
 
[Abort, I've confused myself. I want to insert n elements T(getX(), getY(), getZ() without making a copy, but I got lost.]
What's forward_as_tuple?
 
A utility to create 'argument packs'
There's a use for it for a constructor or member that forwards to a pair
 
But basically yes, I want to be able to "assign" to the emplace-iterator the constructor arguments directly
Nice
 
12:19 AM
Great minds think alike!
 
:-)
 
Sorry to interrupt, but what's this emplace thing you're talking about?
 
So yes, you got it - the purported iterator would have to be assigned a suitable collection of T-constructor arguments
 
@MartinhoFernandes std::vector<std::pair<int, long>>().emplace_back(42, 42);
 
your tuple forwarder is exactly the right thing!
 
12:20 AM
It's not mine, it's standard :)
 
Nobody owns the standard!
 
Also functors would use std::make_tuple to return locals.
 
(Not at ISO's pricing scheme at any rate.)
Right. So if I have a functor F that provides tuple<Args...> operator()(), then I should be able to call generate_n(emplace_iterator<T>(v), n, F()), where T::T(Args...)` is the constructor.
 
Yes
Warning: unpacking a tuple is not straight-forward
(or it might be for you, I don't know)
 
Hmm, n3290 has only priority_queue::emplace, forward_list::emplace_after, and forward_list::emplace_front. There's no such thing on vector. What am I missing?
 
12:24 AM
It seems that with C++0x one should have emplace everywhere and be rid of inserts, because the inserts would always just create an unwanted copy... OK, unless you actually did want to insert a copy.
Wait, no emplace on unordered_map? Could have sworn I saw that.
 
Plus the caller must have the object handy
 
Oh wait, that's only what is on the index.
 
Hey, I've worked with unpacking arguments before, thou shalt not scare me.
 
I don't see emplace[_back] in the synopsis for vector but GCC has it implemented
 
It is there.
But for some reason, it's not on the index.
 
12:28 AM
Which index are you guys referring to? The TOC in the PDF?
Oh, d'oh, the index in the PDF?
 
No, the "Index of library names", near the end.
 
I only have 3242 :-(
 
@KerrekSB I found a much much less verbose way that I'm now using everytime. It costs an overload however. I'll show you.
 
@LucDanton Yes, the caller needs to have the arguments ready. But I imagine that that's a plausible scenario.
 
It's acceptable when moving is cheap.
 
12:33 AM
Cool. Where is it? Do you have a gist?
I guess an emplacing version of fill_n would be handy
I.e. emplacing iterator plus tuple.
 
@KerrekSB Here
No reason that decltype should be commented
This works for any tuple-like type for which get<I>(tuple) is well-formed for 0 <= I < std::tuple_size<Tuple>::value.
 
12:49 AM
Hah - variadic ints! Very nice.
 
Anyone care to help with a SQL problem?
0
Q: How to integrate feedback score into search results

bigmike7801I am currently running the following query that returns a set of jobs along with their categories and the user name of the person who posted it. SELECT job_id, user_id, title, profiles.user_name FROM (jobs) JOIN profiles ON jobs.user_id = profiles.user_id JOIN job_categories ON jobs.cat_id = jo...

 
No. I'm at 15666 rep, I'm feeling evil.
 
What's feedback_total -- some aggregate?
Get the aggregate from a subquery, select as feeback_avg and add WHERE feeback_avg > threshold, I'd say.
@Luc: get<Indices>(tuple)... is a cool idea.
So is there an std version that does the same thing?
 
Any chance you could post as response that way I could get a better idea of what you mean and I can give you an upvote?
 
@bigmike7801 Not until you tell me what feedback_total is. Otherwise I'd have to guess half the answer.
 
12:56 AM
@KerrekSB Not really. Tuples in variadic function templates are largely useless; you can only forward/pass them around.
 
feedback total was a variable i was using that would add all feedback scores together from all results for a particular user
 
@bigmike7801 Can we at least simplify and assume you have one single table of feebacks with fields employer_id, score, and maybe one employer table?
Assuming you can fill the real situation in from there?
 
sure
            foreach ($query->result() as $row)
           {
		      $feedback_total = $feedback_total + $row->performance;
		      $feedback_total = $feedback_total + $row->quality;
		      $feedback_total = $feedback_total + $row->availability;
		      $feedback_total = $feedback_total + $row->communication;
           }
           $feedback_avg = ($feedback_total/$num_rows)/4;
That was the php I was running to get the feedback and it works just fine, except it's running as a seconday and does not let me sort or filter my main query
 
Nah, do it in the DB. Take a look, I posted an attempt.
 
Is that fact that I'm using a 3rd table going to make a difference?
 
1:13 AM
My two tables correspond to your entire collection of tables. You just have to make sure that there's an appropriate view that looks like my feedback table
There's nothing magical about chaining all your tables together. What matters is that at the end of the day you have one table (or view) which lists all the feedback
Small fix. Tested it, too.
 
oh nice thanks!
 
I added a view for ease of eye
You should definitely also make a view of your many tables!
 
1:31 AM
I haven't heard of a view before
How do you get the text blue in code mode in Stackoverflow?
 
Views are key. Start using them today.
I don't know about the highlighting, it sort of does it automatically.
Just use a code block and all will be fine
 
You just write it. It's automagic. As long as the question is properly tagged you get highlighting.
 
Ah, is that how it works -- I was wondering if there was some language recognition magic
 
In the early days there were some language recognition heuristics. But they changed to tag-based some time ago.
You can also force the language on a block-by-block basis with special markup. I can't quite remember what it looks like, though.
 
Oh noes, that would have been interesting!
 
1:41 AM
Here:
24
A: Syntax highlighting language hints

Jeff AtwoodNote that this question is a bit obsolete, because we now infer prettify language type based on the tags. See more: Changes to syntax highlighting This is now implemented. In addition to tag inference (a recent change), you can manually specify the language as a hint to Google Code Prettify. T...

 
Good stuff!
@bigmike7801 How's that upvote coming along? :-)
 
Just fine ;)
Sorry about that
 
Hehe, thanks
No worries
I had fun
 
I'm at work and trying to juggle a few things at once
 
Is it working out, though?
 
1:47 AM
are you on here quite a bit?
I haven't had a chance to try
will try in about 10 to 20 minutes
 
Nah, I'm about to be off. But I'll be around tomorrow.
Do play with it, though, SQL is a lot of fun
 
I will
 
I'd wager that you can solve most of your tasks with pure SQL
 
thank you so much for your help
 
In fact, 90% of my every-day advice to people is, "you need a database".
Little do they know...
No problem.
 
2:13 AM
template<typename T> T* make() { return new T(); }
std::generate_n(back_emplacer(c), 42, &make<U>)
@KerrekSB That's what the OP is trying to achieve
But without the wrapper
 
uh what?
 
Are you Kerrek?
 
2:28 AM
Anybody around?
 
Hi - yes, indeed
Without the wrapper.
But rather than saying generate_n(back_emplacer(c), 42, a, b, c, d), I'd be happy to say generate_n(back_emplacer(c), 42, make_tuple(a, b, c, d)) if that's easier to handle.
I guess one could write an auto-boxing overload :-)
template <typename ...Args> void f(Args... args) { g(tuple<Args...>(args...)); }
 
I like using tuples as-if C++ supported multiple returns.
 
Hey KSB
 
Yeah, that's a good philosophy.
Hi
 
2:42 AM
I was mostly able to run with your answer except for one problem
How do I get people with 0 feedback score to show up?
 
Now I want an SQL "best pratices" guide. Apparently INNER JOIN ... USING(...) is the way to go. But it requires that all PK columns have globally unique names.
replace "JOIN" by "LEFT OUTER JOIN"
And then there's some function that returns some value if some other value is null, but I forget what it's called
Oh, it's called "IF"
IF(field != null, field, 0)
Or even just IF (field, field, 0).
 
that goes into the SQL?
is it using a ternary operator?
 
It's like your C A ? B : C. In SQL you say IF(A, B, C).
Wait wait wait
I'm an idiot, we don't need total and num_rows at all
There's a built-in AVG
d'oh
 
There, added.
Oh, COALESCE was the function I was looking for: COALESCE(field, 0).
 
2:55 AM
One problem
I'm using AVG(performance + quality + availability + communication) AS avg_score
 
OK
So?
 
because those are all the fields that need to be added together to get the average score for one
 
Yeah
Does it work?
 
so right now it's giving a result 4 times what I expect so I think I need to divide by 4
AVG((performance + quality + availability + communication)/4) AS avg_score
dles that look ok to you?
 
Have you tried it?
 
2:58 AM
yes and it works
 
There
You can say AVG(A+B)/2, one less set of parentheses.
 
hmmm
where were you saying the COALESCE should go?
 
If you say SELECT a.x, b.y FROM A LEFT OUTER JOIN B ON(A.id = B.a_id), then b.y might be NULL.
So if you want it to be 0 in that case, use COALESCE:
 
you lost me at If
lol
 
`SELECT a.x, COALESCE(b.y, 0) AS y FROM A LEFT OUTER JOIN B ON(A.id = B.a_id)
Just try using the outer join. You'll see that you get NULL everywhere where there isn't a match in the right table.
 
3:05 AM
oh the outter join already worked
but returns a null value
 
But if you don't want NULL, but rather 0 (zero), then this is a handy way
 
but I can work with that
 
You don't want NULL. It'll break stuff
 
thanks again for all of your help
 
make it zero right there and then
 
3:06 AM
oh
SELECT job_id, jobs.user_id, title, description, commission_min, commission_max, skills, post_date, upgrade_border, upgrade_highlight, profiles.display_name, COALESCE(avg_score, 0) as avg_score
FROM jobs
JOIN profiles ON(jobs.user_id = profiles.user_id)
JOIN job_categories ON(jobs.cat_id = job_categories.cat_id)
JOIN job_sub_categories ON(jobs.sub_cat_id = job_sub_categories.sub_cat_id)
JOIN (SELECT employer_id, AVG((performance + quality + availability + communication)/4) AS avg_score
FROM feedback GROUP BY employer_id) AS sq
doesn't quite seem to work
only returns those with scores
 
Because you didn't make the join outer.
 
damn, thought I tried that already
you know something?
YOu're kinda brilliant aren't you?
 
That's what she said
Nah, I'm kidding, it's really not that much magic, you just build things up bit by bit. If you play with SQL for a while, you'll get the hang of it in no time.
 
tWell I've been using it for a while but not for advanced querying. Just enough for basic search results. But as you can see, now I'm working with a little more advanced stuff.
ok, it's getting late. I should head home. Thanks again!
 
3:29 AM
No problem!
 
 
1 hour later…
4:53 AM
Hello all. Given an object, is it possible to find if the object resides in the stack or in the heap. We dont know anything more about the object.
 
 
1 hour later…
6:07 AM
Yo dawg, I herd you like iterating, so I put a vector inside yo vector so you can iterate while you iterate.
3
 
6:25 AM
Morning!
Does anybody have any idea how to compile on Cygwin targetting Mingw64 project's compiler?
Simply adding --target=i686-w64-mingw32 to configure script's command line does not seem to work.
 
@wilx You can always use binary builds from the project
Mmh I'm not sure I properly understood what you are doing. (i.e. what is being configured)
 
@LucDanton: I have Cygwin installed and it contains the Mingw64 toolchain. I am asking how to use that toolchain in Autotools enabled project.
What is being configured is some library.
 
Supposedly either the configure script works or it doesn't because it doesn't support the target.
I guess you're beyond that already...
I would have thought specifying the target for configuration would only be used for cross-building/arcane stuff.
 
7:26 AM
Never mind, I have used the wrong switch. --target is to specify what platform the library being compiled should target, if it produces any output itself. --host is the platform that the library will be running on.
 
sbi
@jalf :)
 
8:36 AM
@jalf Haha. Sounds about right.
Woo, 99 badges.
 
sbi
@MartinhoFernandes Seems they handed out hundreds of badges ~5hrs ago.
 
Yeah, I noticed. Got "Nice Answer" and "Good Answer" for some rather old answers.
 
yeah, I got 7 badges
 
For some answers that had already produced other badges dependent on upvotes, like ages ago.
 
I didn't check what they were for, just noticed the "Nice answer and 6 other badges" in the top bar thingy
oh wow, I got the much coveted badge
 
8:45 AM
So, you know all about strings huh?
 
Everything!"
 
What does that mean?
 
Ask me about strings!
ooh, also silver badge
 
sbi
@jalf Explain that string theory thing to me, please.
 
a string is something you can use to tie things to other things.
kinda like shoelaces
that is my string theory, and I'm sticking with it!
 
9:43 AM
How come void main is seen so frequently?
You don't even have to write a return if you write int main.
So there's really no reason to even want to do that.
 
9:58 AM
> You don't have to sacrifice everything you believe in just to make it a quick fix. – tdammers yesterday
 
@MartinhoFernandes: Bad tutorials.
 
Yeah, I know :( It was a bit of a rhetorical question.
 
question!
should questions be also tagged with ?
ive seen recent questions leave off which is weird
 
I usually do.
 
because c++0x is still c++
2
 
10:08 AM
And in the future we want them to be tagged , of course.
 
yesterday I got 12 badges at once
weird
 
@JohannesSchaublitb yeah, seems everyone just got a whole bunch. Not sure why
 
sbi
10:53 AM
@JohannesSchaublitb Most of us got a whole bunch of badges.
 
0
Q: Why might std::bind1st be considered "almost unusable"?

Tomalak Geret'kalDuring a conversation on boost::bind, it was noted that std::bind1st exists in C++03, but that it is "almost unusable". I can't find anything solid to back this up. The boost::bind documentation says: boost::bind is a generalization of the standard functions std::bind1st and std::bind2n...

 
Xeo
@JohannesSchaublitb The wiki even encourages to tag it with too
 
11:08 AM
@sbi Already using it.
 
11:24 AM
Could someone help me with C++0x? I cannot figure out the syntax for initalizing an array class member in the ctor-initializer using initializer lists:
struct Foo { explicit Foo(int) { } };
`struct Goo {
Goo() : x{ Foo(4), Foo(5) } { }
Foo x[2];
};`
Syntax error after x in Goo::Goo().
 
Compiler?
 
hi
 
Hi - GCC 4.6.0.
g++ -std=c++0x
 
Hmm, no idea. I think it should work, but maybe GCC hasn't implemented it yet.
If you use std::array it works.
 
11:36 AM
I thought that with C++0x we can finally have array members and be able to initialize them.
I also disovered a bug.
Yes, array is probably the way to go
 
Should we close this as a dupe of the linked question?
 
With x({{Foo(4), Foo(5)}}). A lisp programmer's dream come true.
 
0
Q: Real life examples of xvalues, glvalues, and prvalues?

M3taSpl0itHya , i was wondering if anyone could tell or explain some real life examples of xvalues, glvalues, and prvalues?. I have read a similar question : What are rvalues, lvalues, xvalues, glvalues, and prvalues? but Didn't understand what everyone meant . Can anyone explain in what cases these valu...

@KerrekSB The parens are not needed. Only the double braces (it's aggregate initialization of the member C-array, I think it's called elems).
 
Keep talking...
 
@Martinho: No, I don't think so
the linked question is very technically heavy but doesn't really give that much in terms of easily understandable examples
 
11:39 AM
I can't make any other syntax work
 
either it should be improved to include that content, as it is a FAQ question, or the existing one is not a dupe
 
@KerrekSB x{{...}} works for me.
@DeadMG I'd rather have that.
 
It gives me no matching function for call to ‘std::array<Foo, 2u>::array(<brace-enclosed initializer list>)’
 
as long as the FAQ question does not include that content, which right now, it doesn't, then the new question is not a dupe
 
@KerrekSB Is this with GCC 4.5?
 
11:41 AM
4.6
4.6.0 to be precise
Downloading 4.6.1 as we speak
 
Weird. I use 4.6.0 and this compiles (initialization on line 24).
 
Perhaps there's a difference between PODs and non-trivial objects?
 
@Martinho: Ok, I thought of another problem
void f(type t)(std::vector()(t) vec) // how the fuck am I gonna implement that
 
12:00 PM
@MartinhoFernandes How's the h declared? Take a look at this, it doesn't compile.
 
Why do you think this question deserves downvotes?
 
@DeadMG Hmm, crazy. I'm off to lunch now, but I'll have free time to talk about this in the afternoon.
 
10
A: Free gives error

Armen TsirunyanThe code that works "correct" has undefined behavior. It's just (bad) luck that it works. Actually seeming to work is the worst that can happen as a result of UB(doesn't raise your alarm). The other code that doesn't work has undefined behavior as well. You may call free only on pointer returned...

 
@KerrekSB ideone uses GCC 4.5, which as I recall doesn't support uniform initialization fully.
My sha1::h is declared as std::array<unsigned,5>.
 
@MartinhoFernandes I see. Could you possibly confirm that that exact code does in fact work on a different compiler?
 
12:10 PM
bbl
@KerrekSB Yes, the code in that repo compiles with GCC 4.6.0.
$ g++-4.6.0 --std=c++0x -Wall ...
 
No no, I meant my code
You see, I just tried...
and array<int,2> indeed works great
 
Oh, I don't have GCC here, only at home.
 
but array<Foo,2> don't
any compiler will do -- I just want to know if I speak correct C++ in principle
Maybe there's a clause that requires std::array's parameters to be aggregate or POD or default-constructible?
 
Do you have a C++0x draft available?
 
Let me check
 
12:13 PM
N3242. Have a look at pages 746-.
Now, I'm off to lunch for real. See ya.
 
See you!
Ahh, just in, this ought to be fixed in 4.6.1!
In any event, we'd be stuck with still not being able to construct every possible member in a constructor, which would be a disappointment
 
Xeo
12:38 PM
Oh, hi @Kerrek. Nice to see you found your way into the madness!
 
12:53 PM
Please tell me that today we won't be discussing PHP, self-awareness and C++ books
 
It would be nice to avoid monkey sex also.
 

« first day (264 days earlier)      last day (4699 days later) »