« first day (780 days earlier)      last day (4168 days later) » 

1:00 AM
-1
Q: Making a single pointer point to an array of pointers and pass for both C++

Palace ChanI have a struct like this one: struct foo { IBar* ptr; }; which is part of a foo object with a long lifetime. Users often get instances of those objects in different callbacks and sometimes they inject stuff into the IBar* in certain places, use it in later callbacks, free it eventually. (...

 
@Xeo I'm not judging.
 
Xeo
(Temporarily taking over the role of the robot to link to that specific article.)
 
i like the start of it: the foo struct is "part of a foo object"
 
user image
24
 
Ell
Hallo Alf
 
Xeo
1:01 AM
@Pubby lol!
 
@Pubby lol
 
Ell
Just saying hi :P
 
@Pubby lol
 
Xeo
@Mysticial: The lambda question is getting some good votes, I must say.
 
1:03 AM
@Pubby Smooth.
 
@Xeo Yeah seriously... It has 700+ views. I have no idea where they're coming from.
 
@Pubby how such old screenshots surface, not to mention, why were made?
 
Xeo
Me neither, and the votes are kinda tickling in.
@Cheersandhth.-Alf "old"? That thing is just from a few mins ago.
 
@Cheersandhth.-Alf Scroll up.
 
huh, i had somehow imagined Etienne with much higher rep
 
1:04 AM
@Mysticial Wow dude, you planted that question 19 days later
 
and not concerned about it
 
Impressive.
 
@Cheersandhth.-Alf I don't really post answers anymore.
 
Hey folks.
Question.
 
Oh woah... that int->double->int question is on the multicollider...
 
Xeo
 
i just post answers when i feel like it, like, more people than the OP can benefit
 
I'm trying to compile a simple program in the terminal and I'm getting some linker errors.
 
@Xeo But it's pretty far down though.
 
Xeo
Well, it's still on that list!
I was kinda wondering why the question didn't enter the multicollider, though.
 
Hang on, I need to post stuff.
 
1:07 AM
@Xeo Not enough answers. And I got too many downvotes.
 
Xeo
Hmm
@Moshe Hopefully not directly into the chat. :P
 
sehe did a pretty good job of killing it though.
 
@Xeo lol, no github.
 
+26/-5
 
Xeo
@Mysticial Yeah. I don't really understand why he insisted on leaving the link, but oh well.
 
1:08 AM
@Xeo You have to understand that sehe has something very against anything that even runs the risk of becoming popular.
 
Xeo
Eh.
 
He only believes that "good" content should get a lot of votes, and is extremely against anything that isn't "good" that gets votes.
His close-voting and comment patterns strongly support this.
But I can't blame him though.
 
Xeo
Well, except if something is "good" depends entirely on the viewer.
 
I suspect some level of jealousy involved, so the only way for this to change is if he snags his own +100 at some point.
Which I'm more than willing to help him to that.
 
is @sehe against some question?
 
1:11 AM
k fuck variadic templates
maybe another day
 
Xeo
@Mysticial I don't think he'd be the only one that has some levels of jealousy with you and your rep/upvotes/hardware :P
Anyways, I think I'll just plink him, since this is about him. Not like we have to hide anything.
@Rapptz What's your exact problem with them?
I'm more than willing to help, but I need concrete points where you have problems.
 
I can't find any good reference to start and the simple printf example is confusing me, lol
 
Xeo
@Cheersandhth.-Alf Against @Mysticial's kinda-staged jeopardy-like lambda-syntax one.
 
@Xeo it might also depend on context and the viewer's mood.
 
Xeo
1:14 AM
@Rapptz Okay, simple exercise: Write a metafunction (aka class template) that sums all of its arguments.
 
Staged in that I knew the answer when I posted the question. But I didn't know the answer (and couldn't figure it out) when it came up in chat.
 
Xeo
@Moshe "Professor Langsam" -- Seriously?
 
i remember that question. it's just about not having seen a c++ lambda before?
 
Xeo
@Cheersandhth.-Alf At the core, yes.
 
@Cheersandhth.-Alf I've seen maybe one or two examples of it before. But not collapsed like that.
And I've never used them.
 
1:16 AM
@Xeo Yes, what's the problem?
 
So that why I was confused as hell.
 
Xeo
@Moshe "Langsam" is "slow" in German.
I thought it might be a joke on the Professor's lesson speed. :P
 
@Xeo I'm aware. Many Jewish last names are German words or combinations thereof. The man is a genius, no worries about his name.
 
there's an even more confusing thingy in python, a syntax that's not used in the core libraries at all
but it's used in matplotlib
i think it was
for indexing
my mind is a blank
 
@Mysticial There's nothing to fear about Template Masturbation. Other than its addictive qualities or - when you first learn it - the incessant nag to use it as the fuel for the cannon to splash everything with.
 
1:22 AM
@Xeo I can't compile using "gcc main.cpp". Why not?
 
@Moshe what error message do you get
 
user406009
@Moshe Have you tried g++ main.cpp? That might fix a couple of linking errors.
 
yes, should use g++ not bare gcc
 
Variadic templates and horrid shouldn't be in the same sentence! :) — GManNickG 1 min ago
 
Xeo
@Mysticial I just wanted to link that!
Btw, I thought <pre> ... </pre> would conserve <...> - seems it does not. :(
 
1:30 AM
What kind of syntax is this?
C operator ""_C
 
Xeo
@Moshe That's one large file with a lot of unnecessary whitespace. :s
 
C is return value.
 
Xeo
@Mysticial literal operators.
The correct syntax is C operator"" _x btw.
 
@Xeo wut...
 
Also known as user defined literals
 
Xeo
1:31 AM
Wanna ask another "staged" question? :P
 
No..............
 
You can use them like this: C foo = "mysticial doesn't know"_C;
6
 
Xeo
@Mysticial With unsigned operator"" _mb(unsigned long long v){ return v * 1024 * 1024; } you can do 1_mb and get 1 * 1024 * 1024.
 
@Pubby lol that's the first funny one in a while
 
So exactly what does that _C do?
 
1:32 AM
it's a user defined literal
 
Xeo
@Pubby Wow, context-sensitive jokes!
 
... Is that C++? o_O;
Fuck spelling.
 
think like how you can use 1.4f to define 1.4 as a float
 
Xeo
Or 1u to get an unsigned.
 
The underscore + id is just a way to identify what type of user-defined literal it is?
 
Xeo
1:33 AM
@Mysticial It's the name.
 
Rather than writing to_inch(5230) you can write 5234_inch which is prettier
 
Xeo
Those built-in literals are the reason they require an underscore btw.
 
@Pubby ah...
 
So wait.
 
Xeo
And you can write things like auto s = 1_s; auto ms = 1_m/s;
 
1:34 AM
Can I use those in C++? :O
 
Yes
 
Xeo
That's C++11.
 
Fuck, I'm so behind on this stuff.
 
user406009
@ThePhD I think Clang and GCC support them.
 
Holy tits, I like C++0x !
 
1:34 AM
I don't know C, assembly, nor C++...
 
@Mysticial You are missing out!
 
Xeo
Do you know anything at all?
 
@Mysticial I don't know C++11 either :<
 
@Xeo That's gonna be a hard one...
 
Xeo
I wonder if literal operators like _C are allowed, with underscore+capital letter..
 
1:35 AM
I doubt it
 
I'm going to write like a million of those
 
He knows how to compute pi.
 
Xeo
@Rapptz How's your progress on my simple exercise?
 
user406009
Does it need to be a const expr?
 
Xeo
@Rapptz He knows how to write a program that does.
 
1:35 AM
_InDegrees, _InRadians
 
Xeo
@Lalaland No.
 
@Xeo what was it again
 
This is all you need to read to learn C++11 language changes
C++11 (formerly known as C++0x) is the most recent version of the standard of the C++ programming language. It was approved by ISO on 12 August 2011, replacing C++03. The name is derived from the tradition of naming language versions by the year of the specification's publication. C++11 includes several additions to the core language and extends the C++ standard library, incorporating most of the C++ Technical Report 1 (TR1) libraries — with the exception of the library of mathematical special functions. C++11 was published as ISO/IEC 14882:2011 in September 2011 and is available for a ...
 
Xeo
@ThePhD Please don't. They kinda lose their value if the name is so long.
 
@Pubby but...5234 what to inch?
 
1:36 AM
@Xeo Degs, Rads?
1337_Rads
 
Xeo
_deg, _rad might be acceptible.
 
I can't wait to type that ^^^
 
@melak47 as_inch would probably be a better name. Or just inch.
 
The TI-Nspire uses that naming convention for its unit conversion
_in, _m, _km, _N
 
@Pubby But how would the compiler tell as_inch apart from a variable that's named that?
 
1:37 AM
@Pubby That article is going to get deleted soon
 
@Mysticial What? It wouldn't.
 
would that even be a problem? I mean..it's part of the literal
 
Xeo
@Mysticial How can you ever refer to a variable in 1337_inch?
 
Or will be if no one changes it..
 
I personally liked C++0x over C++11
 
1:38 AM
@Xeo The literal has to start with a number?
 
It looks cooler. C++11 is just... boring.
 
@ThePhD Well it's 2011 bitch. Not 2009.
 
3
Q: Can user defined literals have functions as arguments?

PubbyCan functions be used with user defined literals? If so, what shenanigans can be done? Is this legal? void operator "" _bar(int (*func)(int)) { func(1); } int foo(int x) { std::cout << x << std::endl; } int main() { foo(0); // print 0 foo_bar; // print 1 }

 
Xeo
@Mysticial A user-defined literal (UDL) needs a, well, literal. :P
 
^^silly question asked on 11/11/11
That was before compilers supported them
 
1:39 AM
@Xeo ah okay. I was under some impression that you could start it with a letter - which would be ambiguous with an identifier.
 
So wait,
 
Xeo
Either a float (3.14_deg), an integer (1337_leet), a character ('x'_foo) or a string ("holy"_shit)
 
I could define my own _u8, _u16, _u32 literals?
 
Xeo
Why would you?
U"hi" is utf-32, u"hi" is utf-16 and u8"hi" is utf-8
 
I dunno. Maybe to make _u8 return unsigned char rather than char.
 
Xeo
1:41 AM
There are special types char8_t, char16_t, char32_t, although char8_t is just a typedef of char IIRC. :(
 
No it's not.
 
I defined my own for use with the engine, being charutf8, charutf16, charutf32. They're just unsigned char, uint16_t, and uint32_t respectively.
 
Xeo
Oh, isn't? Didn't the robot complain about not being able to overload on it?
 
I mean, no there isn't.
 
I still don't see how these unit literal things are supposed to work...unless there is a base unit defined that shit converts to? I mean.. int x = 1234_parsec; what will the value of x be? 1234? 4025 light years? 3808000000000000000000000000000000000000000000000000000000000 meters?
 
1:43 AM
I also have charcodepoint, which is uint32, but...
.... Eh. charcodepoint's a mouthful.
 
@melak47 It's just an int. It's not converting between units.
 
I'm thinking of shortening it, but I don't know how.
 
@Pubby so what is it for?
 
1234_parsec doesn't have to be int. Or any integral type.
 
@melak47 360_radians <-- That's useful.
 
1:44 AM
@melak47 It's a nifty constructor syntax
 
@ThePhD how?
 
@ThePhD 360 radians? You sure?
 
Can write your whole code in degrees, suffix with radians to convert it to radians.
360_CONVERTORADIANS better? ._.
 
wtf
 
No
 
Xeo
1:44 AM
@melak47 _parsec is what you define. It might be parsec operator"" _parsec(unsigned long long v){ return parsec(v); }
 
@ThePhD but then it makes no sense again
 
Xeo
@melak47 Think of it as SI units. 1_km is "1km"
 
=l
 
Xeo
and 1_m/1_s is "1m/s"
(Depending on how you define the return types of operator"" _m and operator"" _s, of course.)
 
@Xeo yeah, but unless this goes along with types, it's pretty useless isn't it? I mean... 1_km + 4_N - 3_duck
 
1:46 AM
If you don't want an operator"" _km that's not type safe, don't write one.
That's a self-inflicted 'problem'.
 
Xeo
@melak47 As was said, think of them as alternative constructor form - km(1) + N(4) + duck(3)
 
@melak47 I'm pretty sure you'd invoke a typeerror at that point, unless all those types were arithmetic-compatible with one another.
 
@Xeo ah, right. ok that makes more sense :)
 
Xeo
You can return anything you want from those literal operators.
 
Can you write a convert function and use it like convert(10_F) and it'll convert it to other units?
 
1:47 AM
convert<C>(10_F)
 
Xeo
@Rapptz Write a metafunction that sums its arguments.
 
@Pubby that's sexy too
 
Xeo
unit_cast<C>(10_F)!
 
@Rapptz Yes.
 
Just a normal static_cast<C> would work, no?
 
1:48 AM
static_cast seems more appropriate, yes.
 
Xeo
@Pubby Buf unit_cast looks sexier!
 
unitcast, no underscore.
 
@Xeo I don't want to have sex with casts
 
Xeo
@ThePhD Yes underscore. Every cast is written like that.
 
@Xeo Underscores are the devil. :c
 
1:49 AM
@ThePhD boooo
@Xeo and okay I guess I'll try that
 
@Rapptz THE DEVIL I SAY.
 
Xeo
Also, unit_cast is grep-able.
 
@melak47 what?
 
@ThePhD Well you need underscores in user defined literals
 
Xeo
If you want to know where specifically you convert between units.
 
1:49 AM
@MooingDuck sorry, - 3_psyduck
 
Le Sigh. Oh well.
 
@Xeo template<typename... Args> stuct sum : boost::mpl::plus<Args...> {}
 
Xeo
And you can specialize unit_cast as a customization point between units if you can't change those unit type definitions.
@Pubby sigh, it was an exercise specifically for @Rapptz. Also, implement mpl::plus.
 
@Xeo Why?
 
@Xeo Wanna see me implement FizzBuzz too?
 
1:51 AM
I'm supposed to be retarded with variadic templates
@Pubby Already did this though
 
Xeo
@Rapptz You atleast try to convince me you are, it seems. :P
@LucDanton Why would I know?
 
Ye.
With that reasoning you'd never ever use static_cast.
Sometimes an explicit conversion is just that.
 
Xeo
I meant "you can see where you specifically convert units as opposed to casting in general"
Maybe someone wants to know, who knows.
 
58 secs ago, by Luc Danton
With that reasoning you'd never ever use static_cast.
 
k so I suck
:(
 
1:58 AM
What happened?
 
7 mins ago, by Rapptz
I'm supposed to be retarded with variadic templates
 
... So you succeeded in being retarded?
 
Indeed
 
Xeo
@Rapptz Can't get it to work?
 
No
 
Xeo
1:59 AM
"What have you tried?" :P
 
Not a real question. :P
 
need proof of retardation
 
Wow you guys want to hurt what little pride I have left too :(
I got this error: type/value mismatch at argument 2 in template parameter list for 'template<long long int T, class ... Args> struct Sum'
 
@Rapptz It's how things work 'round here.
 
Xeo
If you want public self-deprecation, write "I suck." exactly like that and we'll star it.
 
2:00 AM
Or "I'm an idiot."
 
Xeo
@Rapptz What is a class T param? (Unrelated to to the error.)
@ThePhD Right.
 
3 mins ago, by Rapptz
k so I suck
 
@Rapptz Needs more typename.
 
Xeo
@Mysticial That doesn't pattern-match!
 
It'd help if I had a place to start
@Xeo 0
 
Xeo
2:01 AM
@Rapptz Answer the question.
 
I just tried 0,1,2,3
 
@Rapptz How are you calling the metafunction? (is that what Xeo asked?)
 
Xeo
@Rapptz Not "what is the argument", but "what does class T represent in a template"?
 
sec I'll paste my horrible code
 
Xeo
No, answer the question.
(This is getting interrogation-like. Anyone got a bight light to point at @Rapptz?)
 
2:03 AM
Actually you're right
Why do I have class T o.o
 
This is why you should answer those questions.
 
I got a dark room with no windows.
 
Xeo
@ThePhD Your room? :P
 
@Xeo Unfortunately there's one window. And - it may be the type of glass used to make it - but even with blinds it fucking BEAMS sunlight. :c
I'm all sleeping and shit and then all of a sudden "OH MY GOD MY FACE SO WARM" and the sun's like "GOOD MORNING MOTHER FUCKEERRRRR."
4
 
Xeo
room topic changed to Lounge<C++>: Ongoing interrogation. Do not enter. [c++] [c++11] [c++-faq]
 
2:06 AM
sun
 
Hey, again.
 
good day
 
I'm helping someone with homework, need some help.
Where's my infinite loop?
 
Xeo
@Moshe while(no_clue) ask_lounge(); // <== right here
4
 
@Xeo I'm zombied and it's not my HW anyway.
Supposed to parse a string.
 
2:09 AM
If it's not your homework then why is it at github.com/mosheberman?
 
Very quick C++11 question, if anyone can help... Can I make a (template) function that accepts any lambda and casts it to the appropriate function-pointer type?
(any lambda with no captures, I mean)
 
@Pubby I am obsessively putting all of my programs that I write there. I rewrote the whole thing so I understood it.
 
o_O
 
@ThePhD I do.
 
@Moshe You never actually modify formulaToProcess, so length() should always be > 0
 
2:10 AM
I thought lambdas like that were already function pointers :S
 
substr, IIRC, never modifies the string it has. It returns a new string.
 
Xeo
@Quuxplusone +[]{ /*codez*/ } will give you a function pointer.
 
@ThePhD I assign it to itself.
 
@Pubby They're implicitly convertible to function pointers, but apparently not during template deduction. @Xeo awesome, lemme try that
@Moshe I suspect a corner case with formulaToProcess.substr(1, formulaToProcess.length()-1).
formulaToProcess = formulaToProcess.substr(1, formulaToProcess.length()-1);
 
Xeo
unary + invokes the implicit conversion operator since function pointers allow unary + but lambdas don't.
 
2:12 AM
@Xeo looks like it works!! awesome. thank you.
 
@Xeo I thought it would return a std::function, thanks learned something new
 
@Moshe Read what you wrote carefully:
 if (position == 0) {

                atomicWeight = atomicWeights[currentElement];
                formulaToProcess = formulaToProcess.substr(position, formulaToProcess.length() - position);
                break;
            }
So, position is always 0.
 
Xeo
@Quuxplusone I'd still recommend doing auto* pf = []{ /*codez*/ }; your_fun(pf);
Much cleaner and way more understandable for an outsider.
 
formulaToProcess = substr(position, len - position)
formulaToProcess = substr(0, len - 0)
 
@Xeo why auto *pf? isn't auto pf the same?
 
2:13 AM
forumlaToProcess = formulaToProcess.
Looping. FOREVER.
 
Xeo
@user9000 No, just auto would deduce the lambda type. auto* can only be a pointer-type, e.g. a function pointer.
 
Ah!
 
@Xeo auto pf would work too though, right?
 
@Xeo GCC says that's non-deducible.
 
Xeo
@LucDanton Eh?
 
2:14 AM
@Pubby quite sure it would, since i've tried it before
 
26 secs ago, by Luc Danton
@Xeo GCC says that's non-deducible.
 
Xeo
@Pubby Yes, but it would not yield a function pointer.
34 secs ago, by Xeo
@LucDanton Eh?
 
You suck!
 
Xeo
Wanna continue? :P
 
@Moshe You should save yourself the trouble. Instead of using .find() on the formulaToProcess, you should just get the character at position '0' and do a comparison.
 
Xeo
2:16 AM
But yeah, auto* doesn't seem to work for some reason... meh.
 
if ( formulaToProcess[0] == stuff )  { /* do work */ }
 
Xeo
t.cpp:3:9: error: variable 'l' with type 'auto *' has incompatible initializer
      of type '<lambda at t.cpp:3:13>'
Meh.
Well, thinking about it, it makes sense.
 
@Xeo re "auto": this is for a test harness where I'm going to be doing myTestFunction("foo", +[](int) { return 0; }); myTestFunction("bar", +[](double) { return 0.0; }); ... etc... for a ton of lines.
 
Xeo
user-defined conversions aren't tried during template argument deduction.
 
In normal code, I'd totally agree with you.
 
Xeo
2:18 AM
@Quuxplusone Nevermind the auto*, it doesn't work. :P
 
@Quuxplusone Unary plus seems appropriate for a test.
 
Xeo
I love +stuffz for decaying stuffz (if the decayed stuffz supports unary +, obviously).
 
Woah... I just got an interview offer from Apple for a potential job at optimizing iOS... This one, I'm gonna take seriously.
And Apple is close to home too...
 
Xeo
Get them to allow easy C++ development on iOS, instant speedup.
 
Mysticial will be our inside agent.
He will push C++ into Apple.
 
Xeo
2:21 AM
While knowing neither C or C++.
 
@Mystical - I'm jealous. I am an iOS dev. Just not working for Apple.
 
@Xeo The perfect crime.
 
Xeo
@Mysticial But yeah, cool stuff.
 
Ooh, and see if they cant get pure python support on IOS. I would fangirl.
 
Xeo
So we can blame any future performance problems with iOS on you, I take it?
 
2:22 AM
@ThePhD We can't because we might have multiple characters for an element.
 
@Moshe Oh well then. Have fun!
@Mysticial Go for it! Steve Jobs isn't there. You have a chance.
 
> For iOS, of course, we're much more interested in user-perceived performance than in benchmarks, but on the low-level side we often look at stuff very close to the hardware. In your Stack Overflow posts, it looks like you have a great handle on that type of problem. But just as importantly, you seem to be enthusiastic about, and very good at, explaining those answers. That's exactly the kind of skill set we value...
Damn... I think I'm gonna be thanking SO for the rest of my life.
 
Lol
 
The timing is pretty good too, since I'm about to drop out of the Ph.D program.
 
Xeo
@Mysticial Nice.
The question is, how much of your skills can you use in Obj-C? Or do they actually use C or C++ internally?
 
2:27 AM
@Xeo I don't think it matters. Since I don't know C or C++, there's nothing to lose anyway. :P
 
Xeo
Heh
But what you can do in the language is largly different, I think.
 
I'll respond to him after I finish my homework and after I hear what my Dad says.
 
2:49 AM
sigh so bored...
 
This has had me stuck for a day now:
0
Q: Binary incompatibility between CentOS 6.3 installations

PotatoswatterI built an executable by installing GCC 4.7 as binary into my home directory on a CentOS 6.3 machine. But when I move it to another CentOS 6.3 server, it crashes mysteriously after printing some output. I would suspect data corruption resulting from different DLLs using different runtime librarie...

@Mysticial More like SO is thanking you. And I'll thank you too, if you make iOS faster.
 
If you skip to the end, he grew a beard.
 
Augmented reality needs moar iPhone math operations.
 
@Xeo By the way, how do you do it? The answer I mean. I'm interested because I feel dumb since I'm unable to do it
 
Xeo
What, you gave up? I thought you were contiuing after discovering that class... Args is just wrong.
 

« first day (780 days earlier)      last day (4168 days later) »