« first day (725 days earlier)      last day (4445 days later) » 

00:00
@MooingDuck my idea, Jerry's/Martin's (with moves if available; storing pointers otherwise).
Hi
Wow this chat isnt near what English Literature is...
> I'd contend that an "atomic variable" is purely an invention of the API. Accesses are atomic, not variables. I just need to figure out how to correctly shoehorn the C++ API to realize this.
@BrandonDamante This chat is full of Europeans. It's 3am there.
Actually, you don't need the event, the barrier is enough pastie.org/5027062.
@LucDanton Where's that from?
@R.MartinhoFernandes even better
00:08
I may sound harsh but I get the same feeling as when reading about would-be inventors that look for just the right setup to 'correctly' overcome friction and achieve perpetual motion.
@MooingDuck Full of dedication to literature. They should do something with there life and waste their time on programming in C or C++!!!
1
Q: How to create an atomic variable from a naked pointer in C++11?

Dan OlsonGiven that atomicity is an access-specific property rather than a type-specific one, the need will occasionally arise to convert a naked pointer to an "atomic" pointer for use with the C++11 or C11 atomics libraries. What's the intended way to do this? Using Clang 3.1 I'm trying to use the __a...

@MooingDuck On this side of Europe, it's only 0100.
@MartinJames Europe is wide, and I guessed.
00:10
'purely an invention of the api' boggles my mind. What else is there?
@MooingDuck CEST is currently at 2:00.
@LucDanton No fucking idea.
@MooingDuck do you agree they should be doing something awesome???
I'm willing to agree with you.
Actual and honest magic, of the cargo-cult persuasion I suppose.
@R.MartinhoFernandes Me?
00:12
To steal GMan's line, I think the cases where you want an atomic only some of the time are those when specifying, prototyping, and testing the machinery wasn't a priority.
@BrandonDamante Sorry, I meant Luc :)
I would have considered answering several minutes ago if not for the fact that this is about a compiler builtin and I don't feel like browsing the manual on behalf of the OP. That comment I quoted is... interesting however.
@LucDanton I think the OP is misunderstanding something.
If you mix non-atomic with atomic accesses to a variable how atomic are the "atomic" accesses?
Would first need to check what the builtin actually operates on. No deal!
@R.MartinhoFernandes But do you agree?
@LucDanton I can't even find the manual page.
Xeo
Xeo
00:16
Btw @Luc, solved your "perfect storage" problem yet?
@Xeo I settled on a convention that mirrors C++03's ref. That's about it.
Xeo
Xeo
Mhm
I'm still not sure if a solution should either aim to cover all possibilities, which seems ludicrous considering the number, or only the common cases, in which case I'd like to toy with C++11 a bit more before forming an opinion on what those cases are.
@Xeo What's that?
@LucDanton Manual says nothing about mixing with non-atomics. I'm assuming that means UB.
I know that rvalue -> rvalue is one of the case that I do use. It mimics perfect forwarding, and it's not available with C++03-style (the infamous bind([](std::unique_ptr<T>& p) {}, std::move(p))).
00:20
Well, so I was programming... and uhh, I made a thing that... kind of... yeah.
Xeo
Xeo
Mar 23 at 21:54, by Luc Danton
We need a sister-concept to perfect-forwarding, something with a name like 'perfect-storing'. I'm still not sure what's the preferred way to handle this.
Go from there
Storing is half the story. The other half is, well, restoring.
I think I've called the thing perfect-(re)storing at some point.
Who starred my post
@BrandonDamante CatPlusPlus
Why doesn't he talk
00:24
Wait, March?
Xeo
Xeo
Yes
Did you change your opinion on passing shared_ptr by ref already?
@Xeo (this)
Well I signed up for some Coursera classes.
Hope they are worth it.
WHOA A NEW GUY
lol, you are the new guy.
00:26
HI PLEASED TO MEET U
I thought I was the new guy.
Xeo
Xeo
@R.MartinhoFernandes Kinda. Pass by value if you want ownership, pass normal T& in most other cases, and by shared_ptr<T>& if you explicitly want to modify the shared_ptr.
2
Hi, I'm not exactly new around here.
Xeo
Xeo
Btw, I think you're missing a link there.
TWO NEW GUYS???
00:27
Nah. I'm not really new.
Well, so I was programming... and uhh, I made a thing that... kind of... yeah.
Xeo
Xeo
Did I get the pop-quiz right?
@Xeo No, I was replying to the message I wanted to refer to. The link is the tiny arrow on the left.
Xeo
Xeo
Oh, lol
00:32
I was reading the webplatform.org thing
I don't see the connection.
WebPlatform is organized by these guys as a way to have a central form of documentation among other things.
@BrandonDamante if you view his profile, he's been a chat user since 2012-03-08
@MooingDuck Who
@BrandonDamante Chimera's
00:36
ohh
@Rapptz Yes, but it's not competing in any technical way. It will document all the same things other resources already do. I think the point of the XKCD is that the 15 competing standards are actually different, and you can't mix and match.
Im bored so I'm gonna post the code that I'm still working on...
1 message moved to bin
No one likes to have their screen space taken with code like that.
Use an external service to paste code.
00:42
Like what
@BrandonDamante google.com
check out the recent codes on ideone
A NEW PERSON!!!
00:46
Wasn't the minimum age on SO 14?
...IDK
Im 14 in 2 months
@R.MartinhoFernandes > Subscriber certifies to Stack Exchange that if Subscriber is an individual (i.e., not a corporate entity), Subscriber is at least 13 years of age. No one under the age of 13 may provide any personal information to or on Stack Exchange (including, for example, a name, address, telephone number or email address).
Why don't block quotes work when replying?
Because Markdown sucks.
00:48
I like Markdown :(
Me too.
But the particular flavour that chat uses is broken.
@R.MartinhoFernandes @Rapptz check out my code at ideone
Don't ping multiple users.. And just post a link, not really.. hard..
Erm, you need to post a link to it. (Also, it's bad form to ping users out of the blue)
Xeo
Xeo
@R.MartinhoFernandes Hey, I know I have one since 2 weeks now. :D
Also, how does a robot get a cold?
00:49
@Xeo I didn't notice the other day.
Xeo
Xeo
Is that sarcastic?
Cylons are a race which appear in the reimagined Battlestar Galactica television series and its prequel Caprica. They have several forms, some of which resemble and even mimic the behavior of humans, while others are mechanical in appearance and function. Background The Cylons were created by Graystone Industries on Caprica as the U-87 Cybernetic Lifeform Node initially to serve as robotic soldiers but later as workers. They eventually rebelled against their creators, leading to the First Cylon War. After the arrival of the Final Five, who promised to share their technology in exchange...
@Xeo No, I'm serious.
Oooh, spoilers in the onebox.
This should have video chat
Who agrees
God no.
00:52
Why?
It's.. stupid.
It's.. AWESOME
Why can't I log on Steam :(
I'm not sure that helps.
Copying copies.
I have no idea what I just said.
This head ache is killing me.
I was thinking straighter when I was drunk.
Xeo
Xeo
forwarding from an lvalue of course copies.
01:24
@Xeo What do you mean by "explicitly want to modify the shared_ptr"? I mean, what is the difference of passing T&?
Xeo
Xeo
@VictorHugo The shared_ptr itself, not what it points at
1
Q: Min/max of arbitrary type T in C++11

user1459339Is there a way to assign a variable of arbitrary type T it's minimum or maximum value? template <typename T> void setMax(T& var){ var=MAXIMUM_OF_TYPE_T; //can this be done? } T toBeMaxed; setMax(toBeMaxed); In case that T was int, I could as well do var=std::numeric_limits<int...

this question is silly.
@Xeo Ah, ok! Thank you
std::vector<T> v(std::vector<T>::max_size(), max_value<T>());, ditto with std::string. See? Easy!
@Xeo lol
@LucDanton max_size is not static (the fuck why not, right?).
Xeo
Xeo
@LucDanton Okay, maximum of a mutex?
01:28
@R.MartinhoFernandes Because allocators. Also, I'm not really planning on the code making any kind of sense.
HI IM BACK
Xeo
Xeo
Oh noes.
@LucDanton Oh. I should read on those bastards some day.
@BrandonDamante Seriously, you should get your keyboard looked at. Your Shift key is broken.
They don't know their parents???
01:31
@Xeo Register every mutex of the program in one location. Then, inspect the graph of those mutexes with std::lock to assess their ordering. From there follows which one is the maximum.
hahaha
Check out ideone
Xeo
Xeo
Don't you need to go to bed or something?
Me? No I stay up til 10 on tuesdays
So 24 minutes?
01:37
@Rapptz I'm gonna be on TF2 for the rest of the night if you wanna join in.
I can't even connect to Steam. It's kinda making me mad.
why not?
@KerrekSB: Max of your enum is sizeof of its underlying type multiplied by number of elements. Max of fstream is size of file. Not sure about Java object though. LMAO — Vlad Lazarenko 1 min ago
@Xeo what is <:
@Rapptz Basically
Xeo
Xeo
01:38
@SethCarnegie A digraph. :(
I don't know. I just closed it and I'm reopening.
Im brandon
my last name is confidential
@Xeo aha, good catch
Xeo
Xeo
01:39
Which means <::child will get replaced by [:child (I think <: was [)
Yeah, I don't memorise digraph sequences unlike you guys
I wonder how long it's been since someone actually used a digraph and meant to (not counting purposeful obfuscation)
HI im brandon and im swagilicious
Xeo
Xeo
@SethCarnegie It's just one thing that sticks, since it happens frequently when using templates. Well, actually it happens once. After that, you know it.
@BrandonDamante Hi I'm Xeo and you're getting plonked.
@Mysticial So how was supper?
Whats plonked
01:42
Oh man I forgot I can ignore people.
@BrandonDamante "Brandon Confidential"? What an unusual name!
@Xeo static constexpr T min() noexcept;
Am I missing something?
@SethCarnegie I only ever remember that one, but it's the one that regularly happens accidentally to me.
Xeo
Xeo
Wha, was it really specified as constexpr? My bad then.
01:44
And I only know it is some digraph, and don't really know which symbol it stands for.
Xeo
Xeo
I might have been thinking of initializer_list<T>::size() then
But... they're nothing alike!
Xeo
Xeo
Yeah, it's late.
Xeo
Xeo
I can always blame on it being late.
01:45
You're a horrible failure.
Xeo
Xeo
:(
Any reason why the committee or someone doesn't remove digraphs?
Also, digraphs are done before preprocessing right
Xeo
Xeo
Yes.
... I have to change every .h file I have and separate it out into a .cpp to avoid multiply defined symbols now.
so %:include <iostream> works right
01:48
Curse you, header only, beguiling me with your simple compilation steps and alluring one-file goodness.
Curse you.
Backwards compatibility with code that doesn't use a toolchain that takes the exact version of C++ to compile against and doesn't have tool to automatically convert digraphs into their equivalents. Obviously.
No one uses digraphs
on purpose
@ThePhD Are you using inline properly? Issues with static?
Xeo
Xeo
@SethCarnegie yes
@R.MartinhoFernandes Um. It's a static const variable.
01:50
I have a terrible head ache, but I think you can always make code header-only.
Anytime an issue arises where it looks like you can't, make it a template.
Template all the things.
@R.MartinhoFernandes Yeah, I think you can
Xeo
Xeo
@ThePhD Yeah, you need to define those in one place, if you're speaking about a class member.
You could put it in a function, though, as a static local.
You won't need an extra definition then.
It's a giant conversion table from unsigned short to half-floats, haha.
I don't think I could do it through a function.
inline type_of_thingy f() {
    static const type_of_thingy thingy = here_goes_the_table;
    return thingy;
}
Xeo
Xeo
01:53
table const& get_table(){ static table const t = ...; return t; }
@R.MartinhoFernandes void?
@SethCarnegie Ooops.
Ah.
I guess I could do that.
@ThePhD and in case you were wondering
6
Q: Static data in header-only libraries

Seth CarnegieI am developing a library that will consist of header files only. So far, it contains only classes, which has been fine. However, I have come to a point where I need to have some library-wide accessible unchanging data in the library (that is, not class instance data) for the implementation of so...

Xeo
Xeo
Marked inline if it's outside of a class and static if it's inside of one.
01:54
Ah. I trhink I've confused you. I'm converting the library -from- being header-only.
Xeo
Xeo
Yeah, why?
We're just showing it's not necessary.
Xeo
Xeo
You can make it header-only.
(Unless you really want; sometimes it's better)
@ThePhD Yes, you've confused us all
01:55
It's not longer going to have headers only, because I need to separate declarations and implementations so that I can inter-include interworking parts and have them all work together.
So that what?
So that GraphicsDevice can be referenced in VertexBuffer and VertexBuffer can still be used in GraphicsDevice, as a hard example.
That doesn't make it necessary either.
I'd need to start writing out implementations in Translation Units though, right?
And if I do that it needs to compile.
... It might help to say I have the library as a separate project.
@R.MartinhoFernandes Actually he does, if he needs complete types in both places, no?
01:57
So?
Smart use of declarations can fix anything.
Well, I'm not sure how to smartly use declarations to dodge this bullet, so it looks like I have to have some translation units in there.
Fact: you can't possibly have class A { B b; }; class B { A a; }; at all (proof: what's sizeof(A)?).
From there you can conclude that there's always one point where an incomplete type is ok.
So you can do it all in one header. QED.
@SethCarnegie No. Trigraphs are done first (in phase 1). At least if memory serves, digraphs are recognized during conversion from preprocessing tokens to tokens, which is the beginning of phase 7.
But I can use class A ( B* b }; class B { A* a } and write funcs for A and B after including both declaration headers for A and B, right?
class A;
class B;
struct A { B* b; void f(); };
struct B { A* a; void g(); };
inline void A::f() { b->g(); }
inline void B::g() { a->f(); }
02:02
Won't I need void A::f() { /*...*/ } B::g() { /*...*/ } in a .cpp of some kind to avoid multiple-symbol definition?
Assuming two translation units include whatever file name that's in?
No, make 'em inline (oops, I missed that :S).
... Can I inline giant methods?
Like, huge ones for D3D initialization?
@ThePhD inline means "do not cause multiple symbol definition errors". It does not mean what you think it means.
... Oh.
Okay. So I just have to inline the shit out of everything.
02:04
I guess the header-only is still on!
Is this correct allocation of memory for the following array?

int *A;
A = malloc (size);
@ThePhD That's how you do header-only libraries.
@BicB No array is involved here.
@R.MartinhoFernandes That particular case doesn't exclude the need; you can need to have definitions of functions for example.
for(i=0; i<(size/sizeof(int)); i++) {
A[i] = rand();
}
@LucDanton how about now?
02:05
@SethCarnegie Declarations of functions never need complete types. So you can declare all functions before the types are complete. QED.
std::vector<int> A(size);
@R.MartinhoFernandes No, I said definitions
this is in C btw
@SethCarnegie The definitions of the functions can come after the types are complete.
@R.MartinhoFernandes so you'd have to have multiple headers?
Xeo
Xeo
02:06
@BicB And this room is C++ btw. We dislike C.
The types don't depend on the function definitions, only their declarations.
6 mins ago, by R. Martinho Fernandes
class A;
class B;
struct A { B* b; void f(); };
struct B { A* a; void g(); };
inline void A::f() { b->g(); }
inline void B::g() { a->f(); }
@Xeo there is no room for C, where should I post it then? C++ is similar to C
That example is compilable. I think.
Xeo
Xeo
@BicB No it's not.
@R.MartinhoFernandes If A needs to use member functions from B and also vice versa, you will need to have at least three headers, no?
wait
02:07
@SethCarnegie The type definition doesn't need function definitions, only declarations.
Xeo
Xeo
@SethCarnegie Note that #include is "copy-paste what's in there", so no, more headers are not anything you need.
And there was a C room, but it was frozen due to inactivity.
Ok, so let me try to explain what I'm thinking and you guys can say where it's wrong
You can do everything in one header. You can also do it in more, but you need to be careful with the include guards.
@SethCarnegie Sure. With sample code if possible :)
If A needs to use B's members and B needs to use A's members, then both types need to be complete simultaneously which isn't possible unless you can organise them specially which I can only think of how to do with at least three headers
This assumes that the classes are in different headers
That is, they are two libraries that depend on each other, not two classes in the same library that can be in the same file
Oh, if you want to forcibly separate the types into two headers, then yeah, you get in trouble.
But if the types are so tightly coupled, I wouldn't.
@SethCarnegie I don't think you can have two libraries that depend on each other.
02:12
Why not?
Because they can never coexist separately, and that makes it one library, no?
You may make two libraries because they are a separation of concerns or something
But they're coupled! What kind of separation are you trying to do?
If they're mutually dependent, you don't want to separate them. Because you can't.
I'm trying to think of an example
The thing that you need to accept when you have mutually dependent functions/classes/libraries/whatever is that they can't be separate, and the two form one cohesive unit.
02:16
@R.MartinhoFernandes your argument has merit. I wouldn't separate them either if they are co-dependent.
Even if they separate do two completely different things, if they are dependent on one another to function properly as a library, I can think of no reason not to create a single library.
I think a good rule of thumb is: if you can't test them in isolation from each other, they are not separate.
02:29
I got GIT! I feel ten years younger.
@Drose I'm confused. What?
@Rapptz Git. The version control system.
How would that make you feel 10 years younger?
Because it's not as painful to use as SVN?
Because I've been using SVN, and someone showed me the light.
02:34
:|
I've used SVN for, hell, 8 years? I'm now learning the awesomeness that is GIT. Now I have to learn about these silly little IDE thingies
IDE is just a glorified text editor.
I like vim.
Then stay with Vim. It's greatest flaw is it's steep learning curve (or learning cliff), so if you already know how to use it, then there's no problem.
I got Sublime Text 2 because of this chat and I really like it.
02:37
I got Visual Studio 2010 at work, and 2012 at home.
I also use Visual Studio 2012 as my IDE when developing for Windows, or Code::Blocks otherwise.
I use geany sometimes when I'm feeling adventurous. I know about Visual Studio, all those buttons and icons. =/
All those godawful buttons and icons and menus in caps FTFY if you are referring to VS2012.
that's about 49 too many. (SAVE)
So do you really enjoy working with the command line?
02:42
It's not that I do or don't really, I mean to be fair I have Eclipse, IntelliJ IDEA, NetBeans and I'm sure I have a VS around somwhere. I mean, VIM can use color coding with :syntax on and has autocompletion abilities too.
I get it coded just the same with vim as any of the others, and I can move through directories and code faster in cli
DAmmit, I'm on that weird part of Youtube again.
Ended up on a 9/11 conspiracy video somehow.
Funny how that works.
So what do you guys like about IDE's that would prevent you from using the CLI? Just out of curiosity.
I don't like 'em.
Well, I like ReSharper, but that's an IDE plugin, and only for .NET :(
I'm not a great fan of the CLI. I can use it just fine but I don't really like it.
Yeah I can understand that. I just feel lethargic working through files/directories with a GUI.
02:50
@Drose With ReSharper, I can hit Alt+Enter and have my code written for me.
Surely that's limited. I mean, if I could hit ALT+ENTER and have an entire game written in C++ I'd be in heaven.
Does it just auto-complete stuff you've started?
@Drose It analyzes your code and recommends best practices.
And general awesomeness.
@EtiennedeMartel Oooh I understand, that's cool. Something to toy with for fun then perhaps.
03:04
I think what I like the most is Alt+Enter being a shortcut to "do what I want".
Especially the "linqify this"
I also learned a couple of pitfalls from it.
@R.MartinhoFernandes Yeah, R# is actually great for learning C#.
@Rapptz My rule of thumb is: if your boss won't get the wrong idea if he looks at the screen briefly, it's SFW.
03:08
My workplace doesn't really care as long as it's not actual porn.
(So, excerpts from 50 Shades of Grey are SFW at appropriate font sizes, but bikini clad women are not).
Xeo
Xeo
> The disposal of surplus sodium by dropping it in lake.
o_O
Exactly my reaction.
03:22
лол смешной!
user50049
'Allo folks. I have a possible merge candidate for c++, would a few of you mind having a look at it prior to me doing it?
user50049
Here's the closed question, which has been heavily flagged for merging into the proposed duplicate:
user50049
68
Q: Why are function pointers and data pointers incompatible in C/C++?

gexicide Possible Duplicate: C: Why is casting from void pointer to function pointer undefined? I have read that converting a function pointer to a data pointer and vice versa works on most platforms but is not guaranteed to work. Why is this the case? Shouldn't both be simply addresses into ma...

user50049
It looks like a merge might work, but I'm unsure on how much clean up would need to be done after the merge
Xeo
Xeo
03:25
I personally would rather see the other question merged into that one.
I like the 68 point one better, just judging from the top answer though.
Xeo
Xeo
It's more general (not only void* -> function pointer) and applicable to a wider audience as such.
user50049
I'm kind of leaning that way too. I've never hit the need to know in what I do (actually found both questions kind of interesting). Ok, I'm going to close the other as a dup of the now closed one, and merge the other into that one.
user50049
Hocus pocus ... done
user50049
03:28
Thanks all :)
Xeo
Xeo
Good stuff.
Merged questions are weird. You have a comment from 2011 on a question asked in 2012 lol
Xeo
Xeo
Nothing you can do about that.
I know, can't say I really care. It's mildly amusing in its own way.
Xeo
Xeo
Maybe one could clean the comments from the merge source. /cc @TimPost
user50049
03:31
@Xeo I'm working on that now. Merges need some 'post-op' care (no pun intended with Post)
Xeo
Xeo
heh
Leave the POSIX one though (the first comment), it's applicable to both.
Hmm, no notice? I think merged questions should have some sort of notice about it, so people don't freak out when something feels slightly out of place.
Xeo
Xeo
@R.MartinhoFernandes It's hidden in the revision history
user50049
@R.MartinhoFernandes It's in the timeline / history, as the original no longer exists, a notice really could not point to anything
user50049
I can add a moderator note as a comment though
Xeo
Xeo
03:33
Jason's comment is also kinda out-of-place, since it references nonexistant comments
11
Q: C: Why is casting from void pointer to function pointer undefined?

Manav Possible Duplicate: Why are function pointers and data pointers incompatible in C/C++? In the man page for dlsym, the following snippet has been provided. double (*cosine)(double); handle = dlopen("libm.so", RTLD_LAZY); /* Writing: cosine = (double (*)(double)) ...

@TimPost ^ it does exist!
user50049
@Xeo wth, I thought those were automatically ... (scratches head) things move too fast around here to keep up! lol
Xeo
Xeo
@TimPost I can't see why you'd want the other to be gone, though, to be honest. Better searches and all that stuff.
user50049
@Xeo Classic case of remembering the wrong information to the right question. It's always been that way, I had a brain fart.
Xeo
Xeo
Heh, I see.
@Xeo: where does your avatar come from?
Xeo
Xeo
03:46
@R.MartinhoFernandes, any idea where the O(n) is hiding in every iteration inside the std::sort call from this question?
@Borgleader It's a character from a japanese light novel called "Toaru Majutsu no Index" that also has an anime and manga adaption.
@Xeo How do you know there's an O(n) there?
Xeo
Xeo
@R.MartinhoFernandes OP claims it and the timings kinda show it. Double input, quadruple time
Is it possible it's the call to end()?
std::sort is linearithmic.
03:49
I am trying to define an algorithm to find the k largest elements in an array using a linear search method I wrote, and trying to think of the most efficent/beautiful way to do this, however my brain is going crazy with 100 different ways to go about solving this. can anyone possibly provide some guidance?
@Xeo Check up the definition of big-Oh notation again.
Xeo
Xeo
@Borgleader Inside of std::sort, nothing like that happens.
@R.MartinhoFernandes I think I know what big-Oh refers to (worst-case), what do you mean specifically?
It goes something like this: O(f(x)) means for all x > a, and for k > 0, k*f(x) > T(x).
No but his for loop has one
Xeo
Xeo
@Borgleader That only fills the vector once.
03:50
The part in italics is math speak for "it's irrelevant at small scales" (for some value of small scales, which is denoted as a).
Xeo
Xeo
The whole asort function is only called once.
@Xeo be careful, BigOh can also be the average case too, the definition of BigOh is less than OR equal to
And counting stpes is a much more viable measure than counting time.
Xeo
Xeo
Oh wait, the implementation is allowed to copy the predicate as much as it likes, and if it has impl functions, you get a copy there too.
@Xeo That thing about worst case is wrong.
Big-Oh refers to an upper bound.
You can put upper bounds on the best case if you want.
Xeo
Xeo
03:58
Hm
Best/average/worst case are orthogonal to Big-Omega/Theta/Oh.

« first day (725 days earlier)      last day (4445 days later) »