« first day (669 days earlier)      last day (4505 days later) » 

00:02
Anyone has a copy of Effective C++ handy (I know you do @Fred ;)? Can you quote the rule of three from there for me?
@R.MartinhoFernandes Hm, "rule of three" is not in the index, let me browse the Item titles...
Oh, I thought it was mentioned there.
SO I went to start a C-only project in MSVC. and found out they intentionally only support C90,e ven in the latest version
so I was like damn
I got dev-C++ and ming-w on this machine
@R.MartinhoFernandes Chapter 3 is all about Resource Management, but I couldn't find the Rule of Three in there. Let me check Chapter 2...
and for some reason fseek tells me every file is 2 bytes long and I can read any file for 2 gigabytes regardless of if it is over or under 2 gigabytes
I am annoyed. :-\
regardless I managed to roll my own MD5 from that hack of a mess that was the RFC for it (yeah not just copy-pasting code), and get it to work, but I am so sick of microsoft.
microsoft makes me want to not use their good software because their bad software is so bad
00:10
@R.MartinhoFernandes Sorry, I can't find Scott mentioning the Rule of Three explicitly anywhere in the book.
@FredOverflow Don't worry. I'll pick one somewhere from the Internet.
It's just for a blog post.
67
A: What is The Rule of Three?

sbiThe Rule of Three is a rule of thumb for C++, basically saying If your class needs either a copy constructor, an assignment operator, or a destructor, then it is likely to need all three of them. The reasons for this is that all three of them are usually used to manag...

the ironic thing is loading up code developed and compiled with dev-c++ to debug with MSVC's compiler while dev-c++ sits on its ass cuz it sucks
hey, it's the rule of five now
@CatPlusPlus No, I'm not taking the time for that.
00:11
@FredOverflow Indeed. I don't remember reading it in one of his books. First learned about it from the Wikipedia article.
@std''OrgnlDave I'm going for the rule of zero.
no, its move semantics...
Apparently it's based around LLVM-to-JS compiler.
To compile the interpreters.
LLVM to JS?
10
Q: How to get file size in ANSI C without fseek and ftell?

math4totsWhile looking for ways to find the size of a file given a FILE*, I came across this article advising against it. Instead, it seems to encourage using file descriptors and fstat. However I was under the impression that fstat, open and file descriptors in general are not as portable (After a bit o...

00:13
can I port it to my compile-time metaprogrammed bytecode interpreter?
GHC has LLVM backend, and can compile GHC. This might work!
@std''OrgnlDave I don't think there is any fully compliant C99 compiler out there.
@FredOverflow Oh, that's the one with the crazy guy that says #include <something.h> is UB.
@FredOverflow no, there are, they're just the unpopular ones that big companies make that you hear of but have never heard of anyone using
Oh gods, don't remind me of that guy.
00:15
@R.MartinhoFernandes lol where exactly? :)
fseek and ftell return 2 for me :-(
doesnt really matter atm
> In C if you include a nonstandard header, the behavior is undefined.
lol?
I'm laughing at the ridiculousness of that again.
How do I split my project into multiple files if I cannot even #include "my_foo.h"? :)
00:17
You don't. Linking is probably UB too.
Hell, for all I know, opening your text editor is UB.
That answer is the worst standardese pedantry in the history of SO.
> What's the most bizarre, f'd up pic you've come across on your site? Link please.
> I don't have the links, but you really don't want to see them anyway. Trust me. I've seen a dead man with his penis cut off and shoved in his mouth, as well as a penis that was split like a banana peel.
is #include'ing a non-standard header defined in the C standard, though?
Are you joking?
00:19
It establishes logic by which no C program ever written has well-defined behaviour.
@std''OrgnlDave Of course it is.
Which makes C standard useless.
@R.MartinhoFernandes citation?
The compiler should look up said header in some location it likes and copy its textual contents into the current TU.
How can you post something like that and not see how fucking idiotic the most obvious conclusion is.
And then confirm that conclusion and still defend your post with a straight face.
I just don't get it.
00:20
are you asking me, or the questions linked
> A #include preprocessing directive causes the named header or source file to be processed from phase 1 through phase 4, recursively.
§5.1.1.2/1, phase 4.
lol thanks
"A binary stream need not meaningfully support fseek calls with a whence value of SEEK_END." are you kidding me
this is fucking mingw not some IOCCC C to brainfuck compiler
§6.10.2 is relevant as well (explains where said source file is looked up).
fseek(file,0,SEEK_END) would be a specialized template ... thing ... if it were C++ and that somehow made sense
I'm pretty sure that a compiler automatically optimizes fseek(file,0,SEEK_END), int a = ftell(file) to like one syscall
Guys, I'm tired, but the Lounge is so much more exciting than my bed :(
00:23
Why are you tired in the first place?
Don't tire yourself.
Because it's fucking 2:24 am in Germany.
@FredOverflow well if I was in Germany I would care but I'm not so answer the damn question
Anyone knows how to make footnotes in Markdown?
@std''OrgnlDave What question?
32
Q: Markdown footnotes?

John the SeagullWould you like them? You could have Markdown to have a popup appear to insert the footnote's text [*]. EDIT: you can use a symbol and then <sub></sub>, but that won't give you a link between the place where the footnote occurs and its body text. [*]: A popup similar to when insert...

00:26
@R.MartinhoFernandes I simply cheat, look here for example.
Hmm. I want to use pandoc's Markdown flavour on my blog.
It lets me use blah^[here comes a footnote].
bla bla bla <sup>1</sup>
<sub>1: explanation of bla bla bla</sub>
@R.MartinhoFernandes nice
@FredOverflow Yeah, but that separates the two in the source. I'd rather avoid that.
@R.MartinhoFernandes sure
I'll just put it in parenthesis.
00:28
footnotes are overrated, anyway.
Gotta go to bed now, sleep isn't overrated. Good night!
so I'm working on an experimental compression program and I decided to go full C and I am actually feeling some pain
I never thought that would be the case, missing C++
but C++11 makes me happy
*hmmm
anyhow, c'yall later, thanks for letting me vent
It irks me that MVP isn't entirely gone in C++11.
std::vector<int> v(std::istream_iterator<int>(stream), std::istream_iterator<int>()); // fail
std::vector<int> v { std::istream_iterator<int>(stream), std::istream_iterator<int>() }; // fail
how can the latter fail?
00:43
I know this may be an odd question to ask; but is Linus's hate for C++ as a language lacking in performance at all justified?
@IDWMaster we don't know what traumatic experiences he's had
@Cheersandhth.-Alf Laugh out loud.
Did you hear that he gave the middle finger and the @#% word to NVidia?
The audience just laughed
@IDWMaster His argumentation against C++ was not about performance IIRC.
00:45
@Cheersandhth.-Alf Hmm, I guess this means it's too late for me.
Something about crap devs, IIRC.
@IDWMaster C++ is a horrible language. STL and boost are crap. That was his argumentation.
@StackedCrooked Hmmm. Doesn't sound like a good argument to me.
So he just plain doesn't like it?
00:48
I've read it. Here's why I thought he was arguing performance: "inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app."
@IDWMaster Yeah. That may happen, ...in any language.
Crappy code is going to be crappy.
He seems to be arguing against OOP mostly.
90's C++ style was ugly tbh
And, if I'm not mistaken, you can't use some C++ features in kernel code. E.g. exceptions and rtti.
@StackedCrooked I rarely use those features anyways. Exceptions for control flow --- ugh
"E.g" was probably the wrong choice of acronym since it's a complete enumeration.
00:54
Better ways to handle errors rather than throwing exceptions
@IDWMaster Exceptions and RTTI are pretty crucial I think.
Any parts of Linux use C++ now?
@IDWMaster Don't say that too loud in here ;)
Depends on what you mean by Linux. The kernel has none of it.
GCC is going to be C++ in 4.8.
Not Linux, but GCC is now using C++.
00:56
Throwing exceptions is not a way to handle errors anyway, it's a way to signal them :P
so linus is going to compile his kernel using c++?
@R.MartinhoFernandes This makes me feel very happy. It's a major victory for C++ IMO. Nobody seems to care though.
@mfontanini Fat chance of that ever happening.
What do you mean by "GCC is going to be C++" then? They're "translating" it to C++?
@mfontanini They're pretty much done doing that.
00:57
If C compilers are going to be written in C++ then that means C++ is doing something right :p
But yes, that's what I meant.
then he is going to compile his kernel using a compiler developed in c++
Porting so that it can build with a C++ compiler was the first step. Now the active development is also gonna be in C++.
@StackedCrooked yeah
@mfontanini Most likely :P
00:58
He doesn't compile his kernel.
Users do.
@R.MartinhoFernandes He doesn't?
I bet he does compile it as well ;)
I think he has done so at least once in his lifetime.
Well, he compiles the one on his machine, but he can do it with older GCCs, since they probably support them.
He'll probably stick to GCC 4.7 forever just to avoid a C++ compiler xD
00:59
On his Macbook Air :D
I suspect he installed Linux on it though.
They probably still use 4.2 as a minimum.
Apple still comes with 4.2 out of the box.
That's because they got into clang at 4.3.
Or 4.2.
Clang actually reports itself as GCC <that version> in the version macros, because it's feature-equal.
Guess I program C++ programs more like a C programmer then. Don't use exceptions much, and don't use RTTI.
I could see the performance issues with RTTI
I don't understand, really.
If you need RTTI, how can you make it faster?
If you don't need it, why are you using it?
01:04
I don't need it; so I've never really looked into it.
Well, the worst you get is that your executable is bigger.
But if it really is type information at runtime (similar to .NET and coffee languages), I'd assume there'd be an overhead to retrieving the type information.
Which features require RTTI again? Not virtual methods. But dynamic_cast and typeid. Any others?
@IDWMaster But if you don't retrieve it there's no overhead.
And like I said, if you retrieve it... well you need that, so taking it out only means implementing RTTI yourself.
@R.MartinhoFernandes Doesn't the presence of a vtable have some implicit size overhead that is unavoidable? (Even if you don't subclass.)
01:07
What happens if you use dynamic_cast without RTTI?
@StackedCrooked That's all I think.
@Mysticial I think it's a compiler error.
@Mysticial Nasties?
Hopefully the compiler would reject it.
@StackedCrooked I'd assume that's not true if you don't use virtual methods.
@StackedCrooked The space overhead is from the typeinfo instances.
01:07
@IDWMaster If you don't use virtual methods then you don't get a vtable. Indeed.
too lazy to try it
When using templates you can get loads and loads of types instantiated, and that can mean gazillions of typeinfos.
@StackedCrooked Wait, so enabling RTTI will enable vtables for everything including non-polymorphic classes?
@Mysticial No.
That would be crazy.
And not C-compatible.
@Mysticial No. Once you add a virtual method to your class then it gets a vtable.
01:08
@R.MartinhoFernandes That's what I was thinking...
Otherwise PODs would be in trouble.
Is there a type trait that can check the absense of a vtable?
std::is_polymorphic should do the trick.
is_pod of course. But less draconic.
So if you did a dynamic_cast on a non-polymorphic class, is it a compilation error?
Has anyone actually tried using C++ for kernel development before?
01:11
Ah, maybe is_polymorphic.
not that I've tried to misuse it like that before...
Recently I mean
@StackedCrooked No. struct non_pod { non_pod(int); /* I has no default ctor */ }; // look ma, no vtables.
@Mysticial I think so.
Yeah, that's what I meant with less draconic.
There's no way it could possibly work.
01:12
Less restrictions.
@Mysticial Yes.
You can dynamic_cast to non-polymorphic classes though.
struct i_is_polymorphic : i_is_pod { virtual void f(); };
You could create downcast function that selects either dynamic_cast or static_cast using the is_polymorphic trait.
Probably not a good idea, though (the usual trouble with virtual dtors).
@StackedCrooked That sounds smart.
@R.MartinhoFernandes What is that?
@R.MartinhoFernandes I'm starting to get sleep deprived :p I'll soon degrade in to convolutedness.
@StackedCrooked A class from which you can dynamic_cast to a non-polymorphic class.
01:16
@R.MartinhoFernandes By using dynamic_cast for upcasting i_is_polymorphic to i_is_pod?
Yeah.
I know it looks silly (static_cast would work), but now imagine it's a cross-cast.
ambiguous_cast
dowhateverthehellyouwant_cast
That's a C-style cast.
But C-style cast can't replace a dynamic_cast right?
01:18
Especially not if there's multiple inheritance since the parent and child pointers might not be the same.
What is the idiomatic way to implement non-const method overload in terms of the const method overload? Is this the way to do it?
@Mysticial Nah, it works fine with MI if the classes are not polymorphic (it becomes a static_cast).
@R.MartinhoFernandes So the compiler will apply the correct offset?
@StackedCrooked That's what Scott Meyers suggests IIRC.
@Mysticial Yeah.
01:20
In case of multiple inheritance the this pointer of the most-base class and the most-derived class are the same. The this pointer of any "in-between" classes are different. Is this defined by the standard, or just so on GCC?
You just can't get cross casts (i.e. cast from A to B in struct C : A, B {};).
@Mysticial C-style casts are fine with MI (In fact, if you've used private multiple inheritance, a C-style cast is the only one that can cast from derived to all base classes correctly).
@R.MartinhoFernandes Indeed. But is uses static_cast for adding const. I recall @Xeo mentioning that const_cast is should be used for that.
@StackedCrooked I'd do that because it documents better and avoids potential mistakes (i.e. const_cast will never do any kind of actual conversion).
@StackedCrooked You can't use static_cast to add/remove const (or volatile). Attempting to do so should give a compiler error.
01:22
To add you can, no?
@R.MartinhoFernandes Lol, never tried it. But it works.
To be honest, for such simple functions the code with the casts is longer than the code with duplicated code.
@R.MartinhoFernandes Actually to add, I guess you probably can (since you're allowed to add const-ness implicitly any time you feel like).
Yeah, it would be strange to disallow it.
What's that saying about (not) seeing forests and trees?
01:30
@R.MartinhoFernandes ?
Not seeing the forest because of the trees. Or something like like that.
In dutch is: Door de bomen het bos niet meer zien.
Wow, thanks. :S
In English it's usually something about not seeing the forest for the trees.
@JerryCoffin And it means you're missing the bigger point, right?
@R.MartinhoFernandes Pretty much, yeah.
01:32
@StackedCrooked Ah cool, that's what I wanted.
Focus on detail causes you to miss the bigger picture.
The first rule I learned when scraping sites: always keep a pause between requests. :P
01:51
@StackedCrooked Though I prefer to avoid scraping, when I've done it, I've also made the pause at least somewhat variable.
@StackedCrooked In French: L'arbre qui cache la forêt
@JerryCoffin Yep.
# I use this method in Bash code
WAIT=$((5 + $RANDOM % 10)) # sleep between 5 and 15 seconds
sleep ${WAIT}
"(...) which can handle all kinds of handles." I decided to rephrase that one... :S
TIL: despite the fact that 3ds Max does have a .NET wrapper for its plugin API, it's far from "production ready".
02:04
Ugh, working on a file with three different languages is crazy for syntax highlighting.
Luckily vim lets me switch at will.
Is this the best way to import std::placeholders::_1 at class scope: static constexpr auto & _1 = std::placeholders::_1;.
using namespace std::placeholders; in a detail namespace?
Yeah, but the gain of detail::_1 from std::placeholders::_1 isn't so big.
I could do namespace args = std::placeholders;
But I've been too spoiled with Boost's global _1, _2, etc..
02:10
Or just put them in your namespace.
I don't see a big problem with that. If you're using namespace my_namespace; and you get in trouble, I have no sympathy.
@R.MartinhoFernandes This is sad.
When implementing gtest's unit tests I need to put the tests in Google's testing namespace. However, my code needs to be in my_namespace. So I have to pick one of them to be the "boss" namespace. And the other one is imported with using namespace inside the boss namespace.
namespace testing { using namespace my_ns; } or namespace my_ns { using namespace testing; }
Is it evil that I'm writing examples that use the WinAPI (they are meant to exemplify something else, the WinAPI is just a vector) but won't compile in MSVC (use C++11 nifty features)?
@R.MartinhoFernandes My mother's nephew is a judge and I don't think he'd label it as evil.
@R.MartinhoFernandes MSVC will eventually catch up with C++11.
So it's a future answer.
02:15
Well, I'm planning to post this sometime this week, so...
And it may work with mingw.
Do you dress up when you have a job interview?
Ah, I just go in jeans and sweater.
I guess for software development it shouldn't be a requirement.
I never dress up. I always wear what I find comfortable.
Actually the most dressed up the candidate is the less likely he'll be a good developer :P
I think I'm very lucky to be a developer. If I hear what normal people have to go through in order to get a job. It's a fearsome thought.
02:20
Like what?
Multiple interviews where there are 5 candidates for a single position. A position that is likely far away with long commute and crappy pay.
I know somebody who's a technical writer. Dammit, I wouldn't want his job.
Oh boy...
0
Q: Are Javascript and C++ too similar to learn at the same time?

NekkoRiveraI'm new to both webdesign and programming. I started learning c++ about 4 months ago and I just started learning webdesign about a week ago. Even though I've only been doing webdesign for about a week I feel that I am more than proficient in x html. So I decided after x html I'd learn java-script...

Too similar? HAHAHAHAHAAAAAA
It's not like learning human languages :D
lol
HEY I TOLD YOU THAT CARTOON WAS SAD. That's what you get for not believing me.
@R.MartinhoFernandes Well.
02:47
Looks like the flags are back.
imagine if you got paid a dollar for every rep point you earned lol
$200 a day sounds nice.
TIL GitHub for Windows is implemented with WPF and Rx. Neat. And they deploy with ClickOnce.
If you manage to softcap that is...
More likely though, being active on SO could get you a high-paying job. That's more than a doller/rep-point.
@Mysticial Indeed. A high rep and looks nice on your CV.
true... but if your younger...
which i know alot of people are on SO
02:59
I'm not too sure how age plays.
into jobs
It's clear from my profile that I'm not someone with a lot of work experience. Yet I get a job/interview offer every other week.
@StackedCrooked I don't mention it in my CV.
I'd like to have someone review my next blog post raw.github.com/rmartinho/rmartinho.github.com/master/_posts/… (I think it was @Xeo that mentioned his availability; or maybe it was @sehe; I don't remember and I'm probably just plinking random people :P)
SPAM!!! Bin it!!! jk...
03:24
@R.MartinhoFernandes "get their destructors invoked" not sure about the usage of the verb "get" here. Maybe you should just write "are destroyed".
Does "reference type" mean pointers and references? Or only references? (I guess pointers, since there's mention of dangling references.)
Hmm, only references (pointers are objects). That's a good point.
What's the target audience btw?
Anyone that is past the newbie stage, I guess.
That is probably too dense for someone that is just starting.
Readers should probably be aware of the rule of three already.
(And I'll add links for some other stuffs)
I guess it's also for me, because the Rule of Zero is new to me :)
@StackedCrooked Yeah, the Rule of Zero is the focus.
I went through the rule of three and all that for context, and to make sure the reader understands why the rule of three is important, and in the end, why it's not important.
03:36
A common way for newbies to burn themselves is by not obeying the rule of three, and then passing the object by value to a function (because they aren't familiar with passing by reference yet). That leads to crashes that leave them puzzled for a while :D
@StackedCrooked Yeah, I mention that in passing. There will be a link to the SO question from the .
I don't want to make it so much about the the rule of three but more about picking the right ownership.
Would std::unique_ptr<void, decltype(&::Close)> also work? (Instead of std::unique_ptr<void, BOOL (WINAPI*)(HANDLE)>;?)
@StackedCrooked Yes.
That might be a better idea (less foreign stuff introduced).
I covers some hairyness.
I want to make it real world-ish enough to show real power, but not too complex to make it incomprehensible.
So yeah, getting rid of that thing is good.
03:42
Assuming they know what decltype is.
Oh, I'm assuming at least passing familiarity with C++11.
I liked the format of the Deep C slides. Where you are quizzed and then receive explanation. A bit like in Exceptional C++.
At the very least, I'll entice curiosity :P
curiousguy is up to his old tricks again
@Prætorian One trick pony.
03:44
did his ban mean banned from all of chat for x hours, or just from this room?
@StackedCrooked That doesn't work quite well in the blog format, I think. Well, maybe if I do like Herb and post the question, wait a week/month/year/dammit Herb when will you post the solution to GOTW #105? and then post the solution. But I don't have that big an audience to make that work nicely.
@Prætorian Being an idiot is not a trick.
it's not, and it seems to come so naturally to him
But posting a small program and asking the reader to guess what will happen is a great way to make it a little more interesting.
At least, that would be my style.
This property is often used to handle cleanup of resources automatically AFAIK "This property" is called deterministic destruction. Maybe worth mentioning.
And newbies probably don't know what "automatic storage duration" means. Some might stop reading there :P
Dammit what's up with me critiquing you so much.
What else will call them without involving some not-so-short explanation?
@StackedCrooked It's fine. That's the point.
03:55
I like to say: The lifetime of variables created on the stack is defined by their surrounding scope. If the scope ends then all objects contained within it are destroyed.
But I tend to be too basic at times. I'd want to show them proof with small sample.
I want to assume people know what RAII is.
If you don't know that, you're at the newbie stage.
@R.MartinhoFernandes I sure as hell didn't until I saw it pop up in chat a few months back.
@Mysticial Well, by "people" I meant "readers".
I don't think my blog is a good resource for newbies. The first three posts are about TMP.
03:59
@R.MartinhoFernandes I know. Are you targeting readers that are above or below my level of C++?
@Mysticial Above or equal, I'd guess.
I find writing for newbies quite difficult. I need to explain everything, and that makes it harder to build bigger pictures.
@R.MartinhoFernandes Yeah, writing for newbies in a concise way is almost impossible without some sort of an analogy that very closely matches the situation. Having taught a few random things to my friends back in my undergrad - it's tough.
04:15
@StackedCrooked I like that slide where Bjarne rates his understanding of C++ as a 7 on a scale from 1 to 10.
Yeah. It's rather humbling for the rest of the programmer world.
Exercise in pointlessness.
I could probably use abuse for to have syntax HTML(body) { /*body contents*/ }
Instead of { HTML(body); { /* contents*/ } }
@R.MartinhoFernandes I was once asked this question on an interview.
What did you answer?
9
Lol. That was three years ago. I didn't know half of what I know now.
But I thought I should bluff a little.
But it wasn't pure bluff, I did estimate myself a little too highly :)
Now I'd give myself a 4. If Bjarne gives himself 7 than I can't give myself more than 4.
@StackedCrooked So now you're an 18!
@R.MartinhoFernandes 18 bluff points
They contain a lot of air.
If I give myself 4 now then I guess it was a 2 back then.
Seems about right. But it would be strange to say in a job interview.
I didn't get the job anyway.
Probably for the best. It was at a consulting firm. This means performing temporary jobs at different places. Not really my style.
04:33
@StackedCrooked One of my friends does that.
I definitely wouldn't want it.
I interviewed for the same position, but they found me a better fit for something else and I couldn't agree more after talking with my friend about it.
I suspect it's quick and dirty hacking just to get the job done.
Not very satisfying. And kind of stressing if the customer is paying your boss by the hour.
04:47
The ideal workplace would be where I can work with you guys on some awesome project.
:)
As long as I get to write library code.
Main window, menus, toolbar, controllers, bugs caused by lower level code that reaches up into the UI. That's not your fancy?
Nope, UIs are definitely not my thing.
I think the main issue is that I haven't found a UI framework that has everything I'd like to see.
You mean features? Or implementation side things?

« first day (669 days earlier)      last day (4505 days later) »