« first day (461 days earlier)      last day (4486 days later) » 

8:00 PM
@Mysticial Template meta-programming.
 
ah...
 
How is dividing two template parameters not a constant?
 
@FredOverflow The result of division by zero is not an integer constant?
 
enum and typedefs?
 
Oh, I got the condition wrong, lol :)
@Pubby the basic ingredients of TMP
 
8:03 PM
@FredOverflow using and static constexpr are the way to go!
 
I don't know, I'm an old-school guy. I like the enum hack :)
 
I like the enum hack too. But using is too sweet to pass.
 
What's the best way to evaluate lots of built up TMP expressions?
like ::type::type::type....
Recursively?
 
Write a higher-order meta-function that evaluates its argument thrice.
 
It wouldn't necessarily know how many to use.
Trying to decide if an extra parameter would be best, or to use recursive SFINAE
 
8:07 PM
Do you want to automatically call as many ::types as possible? SFINAE to the rescue, I guess...
 
What's SFINAE for?
 
The 10 won't be known
 
Ah, I see.
 
Too bad constexpr functions can't be lazy :(
 
awesome!
 
Ponies in a meta-program?
 
Can anyone think of a way to get rid of my_little_pony?
 
Maybe the_smooze?
 
There, no ponies: ideone.com/Fn0RF
All thanks to the magical, yet super simple, id.
 
8:21 PM
Oh man, just catching up on the January papers submitted to WG21. So many interesting proposals and discussions! Also, modules!
 
Are you not aware of WG21?
 
I'm slacking.
 
Proceed to 'individual papers'.
Notice that this January 18th update was the latest activity since the publishing in September, too!
 
> A minimal std::range<Iter>
Finally.
 
8:23 PM
@RMartinhoFernandes id should have been in the standard. I usually call it identity or return, the latter being a homage to Monads.
 
There's even a concepts proposal! I think, it's way too long for me to parse. Also I'm tired.
 
@FredOverflow Totally agree. I call it id because Haskell :)
 
> A Preliminary Proposal for a Static if
interesting
 
@RMartinhoFernandes It's not terribly sexy imo (but I'm saying that because I'm eyeing Boost.Range). Still, an early proposal is the best way to get refinements.
@FredOverflow There's two of them!
 
Hehe, digit separators, à la Perl.
 
8:26 PM
@RMartinhoFernandes Haskell's id takes an x and gives you an x, whereas your id template takes a type and gives you a meta-function. Hence I think return makes more sense; it "wraps" the type in a meta-function returning that type.
 
@FredOverflow id is a metafunction that takes a type and gives you a type!
 
Ew, that concurrent queue proposal suggests resorting to type-erasure/using an interface.
 
@RMartinhoFernandes Hmm... dang, I think I was confused by syntax or something, I guess you're right.
 
@RMartinhoFernandes n3326 has reflection-like features, too. But not quite as full-fledged.
 
8:29 PM
> Sequential access to data members and base sub-objects
also interesting
 
Woah, are any of you even superficially familiar with C# 5's async/await?
 
Is std::tie like std::make_tuple, only with references?
@RMartinhoFernandes I saw a talk once.
 
@FredOverflow See n3328. It's the same thing!
 
@FredOverflow Yes, which means it's actually quite unlike std::make_tuple (assuming make_pair is a typo). std::tie, std::make_tuple and std::forward_as_tuple are the three tuple helpers with distinct and subtly different semantics.
 
@RMartinhoFernandes C++ is actually going to get this stuff? When will the bloat end? :)
 
8:32 PM
You get std::tuple<T&...>, std::tuple<typename std::decay<T>::type...> and std::tuple<T&&...> respectively.
I liek tuples.
 
@LucDanton I meant std::tie(some_int) is like std::tuple<int&>(some_int), right?
 
@FredOverflow Yes.
 
Awesome, I have at least one line of code that I can now improve :)
Assuming Visual Studio 2010 already supports std::tie despite its lack of variadic templates.
 
Anyway, I'd better sleep now.
 
hi! :)
 
8:35 PM
@RMartinhoFernandes async made the C# compiler enormously more complicated, didn't it? How bad will it be for the C++ compiler writers?
 
@FredOverflow I think they hacked some macros together for that.
 
Is there a std::tie for good old pairs?
 
@FredOverflow It requires the compiler to rewrite code in CPS. It looks complicated for humans, but it's a very easily mechanizable process.
@FredOverflow 2-tuples can be constructed from pairs.
 
What is CPS, some intermediate code form?
 
@FredOverflow Continuation-passing style.
Yes, the dreaded continuations.
 
8:37 PM
@RMartinhoFernandes No I meant I want to be able to say auto some_pair = std::tie(a, b).
 
CPS = continuation-passing style. The advantage is that you can transform any program into one which only makes tail calls.
 
@FredOverflow Well you are able to say that.
 
You usually do std::tie(a, b) = some_tuple / some_pair.
 
You do get a misleading variable name, sure.
 
But then some_pair will actually be a tuple, right?
 
8:37 PM
Yes.
 
Well, I guess there's no reason to want a pair when there are tuples, really...
bool operator<(const T& a, const T& b)
{
    return std::tie(a.x, a.y) < std::tie(b.x, b.y);
}
yay :)
 
I feel like I shouldn't have mentioned this treasure trove of proposals right before going to bed since it seems I will be missing interesting discussions. Oh well. Off I go.
 
> Today's state of the art in C++ generic and generative programming includes an increasing amount of introspection-driven code. C++11 acknowledges and encourages such powerful idioms; the header <traits> includes many introspection primitives new to C++11
lol, there is no such header, he probably meant <type_traits>.
 
@LucDanton Yeah, and now I won't have dinner anytime soon because of you!
 
8:43 PM
@RMartinhoFernandes If n3326 gets through, one could even say:
bool operator<(const T& a, const T& b)
{
    return std::meta::members(a).value < std::meta::members(b).value;
}
 
That looks weird.
That's the type of std::meta::members(x)?
Wait, is that a neatification of boost.fusion?
 
Oh, operator< is even a use case in the paper.
bool operator<( Rec const& l, Rec const& r ) {
  return std::meta::members(l).value < std::meta::members(r).value;
}
auto tup = std::meta::members(r).value;
> Now, tuple tup is a view of object r. The type of tup is std::tuple<int&, Rational&, std::string&>. It is somewhat similar to writing:
auto tup = std::tie(r.a, r.b, r.c);
 
Kewl, but I see no "tuple foreach" on that proposal :(
It suggests recursive templates to emulate that.
D has "tuple foreach" cries
 
Anyway, very interesting stuff.
Oh, we have a new Working Draft for the next C++ standard :)
 
It's probably the same, but with DRs.
 
8:50 PM
Fuck, there is so much interesting stuff. I won't be able to sleep for days!
 
Need, there's a value_ptr proposal.
I think @Xeo and I called it cloning_ptr.
 
Xeo
10
Q: Implementing comparision operators via 'tuple' and 'tie', a good idea?

Xeo(Note: tuple and tie can be taken from Boost or C++0x.) When writing small structs with only two elements, I sometimes tend to choose a std::pair, as all important stuff is already done for that datatype, like operator< for strict-weak-ordering. The downsides though are the pretty much useless...

 
WTF, the Concept proposal is 133 pages?!?
 
posted on January 20, 2012 by Herb Sutter

The solution to GotW #102 is now live. Filed under: C++

posted on January 20, 2012 by Herb Sutter

JG Question 1. When should you use shared_ptr vs. unique_ptr? List as many considerations as you can.   Guru Questions 2. Why should you always use make_shared to allocate objects whose lifetimes will be managed by shared_ptr? Explain. 3. What’s the deal with auto_ptr? Filed under: C++

 
@RMartinhoFernandes s/Need/Neat/ right?
 
Xeo
8:53 PM
@RMartinhoFernandes I since changed to deep_ptr
@Feeds FINALLY!
 
@FredOverflow See, I'm already losing coherence from lack of food.
@Xeo That's a suggestion in the proposal. Want a bunch of alternative names?
• clone_ptr
• cloned_ptr
• cloning_ptr
• copycat_ptr
• copied_ptr
• copying_ptr
• deep_ptr
• dup_ptr
• duplicate_ptr
• duplicating_ptr
• matched_ptr
• matching_ptr
• replicating_ptr
• twin_ptr
• twinning_ptr
 
I say we adopt all of those names.
 
Xeo
@RMartinhoFernandes I also since changed to policy-based pointers
Should be doable, no?
 
It uses a cloning policy.
(And of course a deleter too)
 
@FredOverflow well, it more or less includes a rewrite of the standard library. I assume that's included in the proposal
plus whatever convoluted and bloated semantics they've settled on by now
 
9:03 PM
@jalf: you may find this one interesting: open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3341.pdf
 
ooh
 
It's rather short though.
 
yeah. And seems unlikely that they'd add something like that as a core language feature any time soon
but interesting
 
1
Q: c++ Why is an array of characters used in tutorials about strings?

Александър АлександровI have seen tutorials that are using an array of characters in order to demonstrate something with a string object. For example thees tutorials: http://www.cplusplus.com/reference/string/string/copy/ http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/ I HAVE seen tutorials that are not u...

Hehe :)
 
Relevant, if you ignore the superfluous apostrophe.
 
9:16 PM
evening
 
Xeo
lol, the reflection proposal
That'd give C++/CLI a headache when using the proposed % for "rich" pointers
 
@RMartinhoFernandes If you want to, you should explain all the niceness of your id or equivalent alias template next time I have the time. You're so full of it ;)
but I'm outta here now
@Xeo that'd give MS a reason not to implement it...
like extended attributes
 
9:38 PM
@Xeo Where?
 
You can use Objective-C++ instead.
 
they should've chosen a $ for "rich" pointers
5
 
They should have used POO, PILE OF
 
9:43 PM
or better some still strong currency
is there a currency symbol for gold?
 
I propose a bling keyword.
You can use it more than once, like long.
bling bling int = 24;
 
hmmm, I thought I was leaving fifteen minutes ago.
This must be my future self
anyways, cya
 
Looks like SOPA is dead for now :D
 
@LewsTherin Really?
 
9:58 PM
SUCCESS!
 
xD yeah! :D Can't wait for MU to go online
 
@LewsTherin MU getting shot down had nothing to do with SOPA.
 
@LewsTherin MU was not taken down with SOPA.
 
Oh. I forgot I did this.
 
What?! I thought it was.. so the timing was coincidental. Who was?
 
10:01 PM
When did I lose control of my life...?
 
@Maxpm LOL
 
Xeo
@Maxpm lol'd
 
@LewsTherin SOPA or not, the authorities can still take down your site. It's just much more complicated to do so. But it's possible.
 
0
Q: Interface to C++ objects through extern "C" functions

n.m.Can an extern "C" function accept or return C++-specific data types, such as references, pointers-to-members, or non-POD classes (by value)? I cannot find anything in the C++ standard that forbids this. Logically, I would expect the standard to say something about it, as the C ABI is not necessar...

interesting question
 
@EtiennedeMartel I know they can, with the tvshack tvlinks hassle... I assumed they were the one who did MU over
 
10:04 PM
Especially if you harbour pirated material, and mention it on your e-mails, and brag how you're profiting from it.
Then the feds get access to that and you're screwed.
 
using extern "C" to avoid name mangling
 
@RMartinhoFernandes That's stupid if anyone would do that
 
@LewsTherin Seems like the MU guys did.
 
@RMartinhoFernandes Agh, jeez. The idiots then. I do know however they remove illegal materials at times
 
> In a 2008 chat, one employee noted that "we have a funny business... modern days [sic] pirates :)," to which the reply was, "we're not pirates, we're just providing shipping servies [sic] to pirates :)."
 
10:12 PM
 
@RMartinhoFernandes xD
 
user142019
lol @ reddit
 
@TonyTheLion 2 vaginas? How the heck...
 
@RMartinhoFernandes don't ask. Is it even possible?
 
user142019
4 X chromosomes.
 
10:15 PM
So, I "don't ask", and you ask me?
 
@TonyTheLion Yeah apparently, very rare..
 
lol
@LewsTherin you researched it?
 
@TonyTheLion :O Of course not ha ha. Was on the news website a few days ago.. not what you posted though
 
@LewsTherin you mean it was on Reddit?
obviously, otherwise that screenshot would have been impossible
 
10:17 PM
@TonyTheLion Dear, Photoshop.
 
@TonyTheLion It looks like it was posted around the same day I read it.. I didn't read it on reddit.
Cba to find the link
 
@RMartinhoFernandes why am I so dense????
:(
 
Xeo
@StackedCrooked It's moderated, I already made a comment. :P
> Your comment is awaiting moderation.
 
> 'I thought it was amazing and it's definitely an ice-breaker at parties'
 
10:20 PM
Bold
 
11:01 PM
@Xeo It's available!
Apparently I used the wrong markup syntax.
 
Xeo
@StackedCrooked It's wordpress, so you can only use basic html
 
dude, I'm 1 rep from being able to edit stuff. So annoying!
 
All my <T>'s have disappeared :(
 
@Emil Your problem is now solved.
 
Xeo
@StackedCrooked &lt; for < and &gt; for >
 
11:09 PM
@Etienne Ah, thanks! Found a bug straight away as well. Oh well :P
 
Xeo
Oh, damn, I used &rt; -.-
 
I can't even edit. How tormenting.
 
Xeo
Yeah
Herb really needs to work on his blog for basic editing and formatting capabilities
 
I think I've seen it before :)
 
Xeo
Maybe.
 
11:12 PM
Bartosz Milewski give reply nr 3.
 
2
Q: What is the best approach to wiping all data off a HDD instantly?

zzatkinJust wondering in case something happens and I need to wipe all my data right away. I don't care if the drive is unusable after wipe.

 
"In case something happens"?
Like what? Feds raiding your house?
 
@Mysticial Drill a hole into it.
That I've been told by someone who works for a company that is specialized in destroying data.
@RMartinhoFernandes Or his wife.
 
Feds raiding his wife sounds wrong.
 
I had overlooked that interpretation.
I would give him the time to destroy his data properly though.
 
11:30 PM
Is it just me, or this is utter nonsense: open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3349.pdf?
 
I didn't know that make_shared allocates the ref-counter and the object in a single allocation. That's quite cool!
 
isn't that basically the reason for its existence?
 
Exception safety too.
Possibly more important.
 
I would have found it cool if only for the compacter syntax.
 
exception safety?
 
11:41 PM
f(shared_ptr<int>(new int), g())
If g() fails, the int could be leaked.
 
ah yeeeah, kind of. But that's such a specialized and rare situation imo
and if you were going to tackle that by adding make_X functions for everything, you'd never stop
you'd need a std::make_vector too
 
make_shared stands out in actually being an optimization as well
 
You can't leak temporary vectors.
There's no new in sight when you create a temporary vector.
 
11:42 PM
true :)
@StackedCrooked as they should. It's not something you want to step into by accident
 
It also allows you to type the type name only once ;)
 
@RMartinhoFernandes And you don't need to type new. Remember, new is bad.
 
Yes, I think I showed that above.
make_shared is a censor.
 
but there's no make_unique, is there? Pretty sure the official rationale for that was that it wasn't necessary, because it didn't give you anything you couldn't achieve otherwise just by writing sensible code
wjhereas make_shared actually allows you to avoid a relatively expensive operation
 
Well, most of the people in this room have their own make_unique.
 
11:46 PM
I don't know what that means, but it sounds smart.
 
anyway, I'm tired. I'd better get some sleep
 
// very subjective comparison:
return unique_ptr<T>(new T(args)); // awkard to type
return make_unique<T>(args); // more fun to type
 
And safer.
 
@StackedCrooked yup, no disagreement there
but it's a mere convenience, something you could write yourself. :)
 
It seems we all did that at one point.
 
11:49 PM
Yeah, that's true, but it could be in the standard library.
 
@RMartinhoFernandes a lot of things could be in the standard library, but they generally need a fairly good reason to actually add them
 
Come on, just look at std::string. How many mere conveniences are there?
 
and "saving me three lines of code" probably won't cut it ;)
 
std::endl
 
11:50 PM
@RMartinhoFernandes I think std::string would have had to go on a strict diet if it was to be added today :)
 
@jalf Yeah, it was bit dishonest to use std::string as an example.
 
You need to bring out the best guns.
 
Xeo
> (That C++11 doesn’t include make_unique is partly an oversight, and it will almost certainly be added in the future. In the meantime, use the one provided below.)
 

« first day (461 days earlier)      last day (4486 days later) »