« first day (415 days earlier)      last day (4530 days later) » 

12:08 AM
My CS professor suggested that by using the STL, largely you can write code without ever using new, and that he generally recommends it. Thoughts?
 
Totally agree on not using new.
But the C++03 standard library is lacking on decent smart pointers.
Guys, I mistakenly closed this as a dupe :( Can I get help reopening it?
-2
Q: How to cin to a vector?

Sean Possible Duplicate: How to cin to a vector I'm trying to ask the user to enter the total amount of numbers then put those numbers into a vector. To then be cout using a function call. template <typename T> void write_vector(const vector<T>& V) { cout << "The ...

Now back to using new. Even if you use smart pointers you need to use new, at least to initialize some smart pointers.
What you practically don't ever need is delete.
 
12:32 AM
@RMartinhoFernandes make_shared?
 
@DeadMG But no make_unique!
(Which I find stupid, btw)
 
an oversight, imo
but fixable relatively easily
 
Yeah.
0
Q: Adding System Calls in Linux 0.01 for a "Semaphore" using C++

Tim BuiI'm trying to figure how to to implement a set of system calls that provide a semaphore (without busy-waiting) module in Linux 0.01. I want these system calls to allow a process to request for a fresh semaphore and use it for process synchronization. I want to write these in C++ but I'm having ...

 
SingletonServerAllocator
lol
 
@DeadMG classnamer?
 
12:35 AM
y
 
So, anyone here has experience in prehistoric kernels?
"drooling idiot" lol
But they are right to point that out in that question. C++ modules need a lot of care to work right.
 
I've been reading a little of the link
it seems to me that the kernel code has a lot of extensions
"struct namespace" and "asm::"?
did they choose that syntax on purpose
 
actually, the answer is probably "yes"
it's one thing to say "We wrote the kernel in C because RARGHWTFAMAGADCAN'TCONCEIVEOFSAFETY"
 
Since he is working with the caveman that is 0.01, it's highly possible that there are no such bullshit identifiers yet.
 
12:44 AM
and another to say "We wrote the kernel in C because we're fucking morons, oh and by the way, we absolutely ensured that nobody can ever use any other language except C with our specific extensions"
 
@DeadMG Well, asm is always an extension.
 
true
but asm::?
that's just asking for it
they could have done what MSVC did and just use the existing compound statement syntax, i.e., asm { }
 
Actually, I think that's what GCC uses.
Lemme check.
asm("movl %ecx %eax");
Or...
__asm__("movb %bh (%eax)");
I have no idea where asm:: comes from.
 
me neither
and "struct namespace"?
 
If I was running Linux I'd grep the kernel sources for that. I'm curious WTF is a namespace.
 
12:52 AM
If I was running Linux, I'd format and install Windows
 
That would be silly. I already have Windows installed.
 
lol
If I was running Linux :P
man
I hate these times
I have code to write, and I know what it is, roughly, but it just won't flow off my keyboard
 
Me too. How's that for coder's block?
 
I didn't sign up to write in Code::Blocks :P
 
Ha, you're both lousy.
 
1:02 AM
@RMartinhoFernandes Ouch!
 
(Says the guy that spent the whole of last week to write three lines of code.)
Oh wait! I wrote that stopwatch!
That's something.
 
Lol, I gotta break and then get back to work. Seeya all soon.
 
lol
but at least the parser will be done soon
then I simply have to bend my mind in several dimensions at once to write the semantic analysis, and all's good
by that I mean I have to deal with LLVM :(
 
What's up with this claim that std::vector needs a default-constructible type? Is that true? Or is that a limited requirement for the one-argument constructor and resize() only?
 
resize() is a copy
pretty sure that it doesn't need a default-constructible type for regularuse
 
1:15 AM
@DeadMG Copy of what??
 
the last element, I think
 
resize() only has one argument.
 
or, perhaps, a default-constructed T
 
Noo.... resize inserts T()
The two-argument version inserts copies of a prototype
@DeadMG That wouldn't make sense for move-only types.
 
@KerrekSB I posted a comment about it.
 
1:17 AM
But, my point is, if you don't use one-argument resize or constructor, you shouldn't need a DC
 
@KerrekSB Oh, I know the rules are different in C++11
 
That answer is at best just an educated guess.
Also, ow, I didn't notice there was a PlayerManager at stake.
 
oh noes!
 
I feel tempted to post the PlayerCeo joke again.
 
oh noes, how could you?
 
1:25 AM
0
Q: C++: Passing pointer to a class while constructing it

nijansenIf I have a class Foo and a method with the prototype void bar(Foo* foo). Is it okay to do: bar(&Foo());? I know it compiles and works, but since I'm relatively new to C++, I was wondering whether the instance created will be correctly destructed after usage, or if I have to worry about anyt...

This doesn't compile, right?
 
MSVC will accept it
but it's surely non-Standard
 
Ah, silly MSVC.
 
@RMartinhoFernandes GCC accepts it with -fpermissive.
 
silly GCC.
 
Who the fuck uses -fpermissive?
That's the nastiest flag ever.
 
1:30 AM
I thought your momma was the nastiest flag ever
 
@cHao Very powerful GCC! Imagine you had a function that needed some lebensraum to store temporary values, and expects you to pass it a suitable arena. Then you could call compute(&BigObject());... :-)
Or even compute(&(char[1000]())); ??!
 
STOP!
You're making my eyes bleed.
Also, what's with the trigraph?
 
Just something that says, "please, use my stack"
 
the WTF operator, didn't you know?
??!??!
 
(Playing right into DMG's mom fantasies.)
 
1:32 AM
@KerrekSB You mean like, alloca?
 
@KerrekSB { char arena[1000]; compute(&arena); }
 
@DeadMG No no, different stack -- the caller's stack
@LucDanton Yes, quite :-)
 
uh, alloca will come off the exact same stack as char[1000]
 
How very non-inline of you :-)
@DeadMG Oh, you mean alloca in the caller's scope. Yes.
But that's unreclaimable
I want "use my stack but give it back"
 
it's reclaimed as soon as the function returns
just write a lambda if you want it back sooner
 
1:34 AM
Hullo folks, 'mback.
 
[&] { compute(alloca(1000)); }();
 
(removed)
 
@DeadMG Between that and Luc D's readable version, I'm unsure which one I prefer...
 
@KerrekSB We've already covered how a utility that accepts an rvalue and returns an lvalue reference to it would be somewhat unsafe, heh :)
 
@LucDanton Ahh, std::stay :-)
 
1:35 AM
lol
 
@LucDanton It made perfect sense in the istringstream case, though!
Oneliner lovers everywhere enjoyed that one
 
Need a standard quote for "can't take address of rvalue". Get cracking.
2
(I'll be happy just with ideas where I might find it, though.)
 
@RMartinhoFernandes 5.3.1/3
 
Too late, already pasting in answer.
 
Clause 5 is like the best core language clause.
(That or I just like expressions.)
 
1:55 AM
Hm, std::unique_ptr<bool[]> appears to be a plausible substitute for the ill-fated std::vector<bool>.
 
Dammit, I didn't get any more votes since I added the standard quote.
I thought this was a surefire way of whoring rep.
 
2:09 AM
@RMartinhoFernandes haha
Yeah that usually works
 
probably because of the time
 
StatefulTaskTimer::flipBusinessCommand()
@RMartinhoFernandes I think my brain wasn't working when I first read about applicative functors, made much more sense when I read it with coffee.
 
Now I just have to decide between watching more ASTL videos and diving into monads.
STL's plastic eye is mesmerizing, so it's a tough call
 
@keithlayne yes it is
I love his one-side-shaded glasses, they make him look like a pirate
 
2:15 AM
that's totally what I thought of too
 
Whenever he says not to do something I must resist the urge to say "Aye cap'n"
Which is in itself a pun
 
he wrote in a comment somewhere that his plastic eye is due to a birth defect...I didn't know people were born with plastic eyes
 
@keithlayne Monads!
(I'm biased.)
 
monads .... donads .... mmmmm donuts
 
@keithlayne " I was born with a birth defect, unilateral microphthalmia (pronounced "mik-rop-thal-me-uh"). It is a very rare disorder, and I have never met anyone else who has it."
Essentially, my microphthalmic right eye is significantly smaller than my normal left eye and is not fully formed. In fact, my right eye's malformed iris is blue, as opposed to my left eye's brown iris. In public, I wear a scleral shell, which is an ocular prosthesis loosely referred to as an artificial eye.
 
2:19 AM
@SethCarnegie seriously, I spent some looking at typesetting the standard from git from source, and I was seriously bummed that I couldn't get it to output with xref links
@SethCarnegie I'll be sure to email him warning that he has a stalker :)
 
Did you try running LaTeX a couple more times?
 
@keithlayne You have to remove the draft option
 
LaTeX is like violence: if it's not working, you're not invoking it enough.
 
@KerrekSB hmmm......is that just an option tag in the tex source or something?
 
It's in the documentclass declaration.
 
2:22 AM
I used to be reasonably fluent in latex, but it's been a while...I used to to type up my linear algebra homework in raw latex (at considerable loss of efficiency) just to piss off my classmates. That was dumb.
 
It's in std.tex. There's a commented line ready to swap with the existing one.
 
@SethCarnegie you still interested in a copy when I fix that?
@RMartinhoFernandes you're such a douchebag. I think I would have figured that out...I just don't have the source handy. :)
 
@keithlayne email who, and yes
 
BTW @standardQuoters, is there an explicit license for the draft source?
@RMartinhoFernandes where can I find a "Punching @RMartinhoFernandes in the face" emoticon? :B
:B == redneck smiley
@SethCarnegie email STL...you clearly know too much about him, you might make @KerrekSB jealous
 
2:28 AM
@keithlayne well it's STL's fault for making all that info public on his website
 
aye cap'n
if I were to latex2html the sources and put them up somewhere, would I get a nastygram from someone?
 
Could be.
The draft copy I have has some nasty words on the first pages:
> This ISO document is a working draft or committee draft and is copyright-protected by ISO. While the reproduction of working drafts or committee drafts in any form for use by participants in the ISO standards development process is permitted without prior permission from ISO, neither this document nor any extract from it may be reproduced, stored or transmitted in any form for any other purpose without prior written permission from ISO.
 
@keithlayne Nah, I already read his website :-)
 
Makes me wonder if quoting this thing all over SO is legal.
 
no kidding
 
2:32 AM
@RMartinhoFernandes Can compiler vendor dev teams talk about the standard in their meetings?
 
certainly typesetting it from source shouldn't be
 
"Nobody owns the standard." (-- "Not surprising at those prices.")
 
@KerrekSB How would I know?
 
Hahahaha
 
I assume making drafts downloadable implies permission from ISO?
 
2:33 AM
Seems like the version I have was not supposed to have been public.
It was withdrawn a few weeks later.
But then, a few weeks after the standard was published, they set up that GitHub repo.
 
source/cover-reg.tex
I could be an ass and claim that making the repo public implied consent, but I know I'd lose that one
 
I really don't care.
 
Just sprinkle all your conversations with "Yarr" and "Scurvy dogs".
 
@SethCarnegie it's good now thanks to the help of @RMartinhoFernandes...how shall I (illegally) transmit it to you?
 
DropBox it, post a link and delete it afterwards.
Hmm, may be hard to DropBox it on Linux.
 
2:38 AM
Type the bits of the binary file into the chat
and I will reassemble them on my side
 
dropbox is fine on linux
 
Honestly, texing that thing isn't that hard.
 
it's just not set up on my vm, but it is on the host...one moment
 
The README actually tells you exactly what to do
 
2:39 AM
@KerrekSB whoever is keeping it must have a real old version of sed or something, it barfed on mine
but I suspect that step was superfluous
 
I see READMEs all over the place but I'm not sure what to do with them
 
@Seth what OS? way easier on *nix, prolly
@Seth read them, duh :)
 
I hope this answer resolves the OP's bepuzzlement, though it's hard to tell what's being asked...
 
whoa, the non-draft version is 3x bigger
 
@keithlayne I think the first command (makegram) can be ignored. The second one is important, though.
 
2:44 AM
@KerrekSB the "make_it_build" branch was useful for me...of course I had fixed the problems by the time I had figured that out
@SethCarnegie Here you go: db.tt/Muh6AzL3
oh shit the ISO thugs are already banging on my door
 
Quick use a kid as a hostage.
 
@RMartinhoFernandes I'd have to get one out of bed, and that would be a pain
 
@keithlayne write using namespace std; on a card and slip it under the door
that should give you enough time to slip out a window
 
you know, my wife probably thinks I look at porn when she goes to bed. I might just let her keep thinking that. She would think I was weird if she knew I was watching STL videos.
@Seth they might burn down the house if they saw that
 
2:55 AM
@Seth you download the file?
 
"thinking My husband is probably watching porn. But I need to be sure." sneaks behind keith "still thinking, but completely flabbergasted OMG, what is this? A one-eyed guy drawing stuff on a whiteboard? What kind of sick pervert did I marry?" faints
 
"what kind of sick pirate fetish is this??"
 
@keithlayne got it thanks
Does anyone know of an ASCII art program, like MSPaint only that lets you work with ASCII arts like arrows and tables, etc
 
wife: "why aren't you wearing any pants!?!"
me: "ummmmmm....I'm more comfortable this way?"
 
Please tell me you're wearing pants.
 
3:00 AM
umm....okay, I'm wearing pants
 
Good, thanks.
 
pity there are no alternatives to LLVM
 
Why?
Is it that bad?
 
because I don't trust GCC
 
@DeadMG why not
 
3:04 AM
my only experience with GCC, and virtually all Unix tools, is spending forever dicking around trying to make them and configure them and endless piles of bullshit
 
There's your problem. You should configure them before makeing them. :P
 
You mean when you compile them or when you write programs and try to compile your programs with them
@RMartinhoFernandes ha
 
endless piles of bullshit
if I were to ship a compiler using it, then I'd have absolutely no faith that it would actually work on anyone's machine
 
@DeadMG Are you talking about unicode codepoints again?
 
no, bitching about LLVM not coming with a linker
 
3:07 AM
@DeadMG Oh OK. It just sounded like a codepoint there for a moment :-)
 
nah
I decided to leave those problems for later
 
Is it normal that code files in different (static) libraries with the same name break the linking process?
 
yes
wait, no
 
Isn't that the purpose of llvm-link?
Or do you mean a library interface to it?
 
what? yes or no? :)
 
3:16 AM
@rvalue llvm-ld can only forward to GCC's linker
 
well I have lib/a/foo.cpp and lib/b/foo.cpp
 
Dang, that's a lot less cool than I thought it was.
 
yeah
me too
 
the build system creates liba.a and libb.a files which then get linked together
 
And you get one copy of any duplicate symbols, and which one is completely arbitrary? Yep.
 
3:17 AM
If there are functions with the same name (including namespaces and all that jazz), then I think it's normal to end up with duplicate definitions.
 
however, lib/b/foo.cpp isn't part of the binary
nope, the namespaces are separate. The files just happen to have the same name
All I would like to know is, if this is a problem in "my" build-system or if I have to take care that no two .cpp files have the same name?
 
I don't think source file names are relevant.
 
That's what I thought so far!
 
Shouldn't be any problem if you don't actually have duplicated symbols - the name of the file shouldn't be the only factor in any object name mangling
Just make sure that the classes are in different namespaces, and any file-scope symbols (i.e. helper functions) are in an 'anonymous namespace'
 
they are!
 
3:22 AM
You should be gold, then =)
 
however, the initialisation code in one of them isn't run
I tested it by inserting the following testclass
 
i.e. a function with something like __attribute__(constructor)
?
 
struct Foo { Foo() {assert(0); } }; static Foo foo;
Foo sits in an anonymous namespace
 
I'd check that you haven't got #define NDEBUG anywhere
 
unless I'm mistaken, this should kill the execution before the main function is entered, but it's not!
 
3:24 AM
and try stepping into it to make sure that's the Foo that's getting constructed
 
Nope, assertions are enabled!
gdb doesn't know what Foo is ...
 
Could be your compiler/linker is eliminating the static object because it knows that assert() has no side-effects and the foo is otherwise un-used.
GDB won't be able to find Foo by name if it's in an anonymous namespace - try to insert a breakpoint by File:line
 
Well, I threw in an std::cout in, just to be sure. It didn't print anything
 
I forget the exact syntax
You could also try static ::Foo foo;
 
Yes, I also tried to put the breakpoint in depending on the file name, but then it chooses the other file with the same name.
 
3:26 AM
ah, shifty little bugger, gdb.
 
If you rename one file, it works?
 
Ah, who knew there was a SE website for biblical hermeneutics...
 
Gotta step out for coffee - back in 15.
 
@KerrekSB I think we need a opencv.stackexchange.com.
 
nope
 
3:28 AM
another thing I don't like about LLVM
it has a C translation unit compilation model
very ugly :(
 
ehm
how do you know I have anything to do with llvm?
 
I don't, and never said you id
 
I see. It just felt spooky! :)
 
you have something to do with llvm?
 
technically; I'm working on a KLEE fork
 
3:31 AM
I don't know what KLEE is
 
ok
 
it uses the same build-infrastructure as llvm, and shares some code :)
 
well
I significantly dislike LLVM
just so you know
 
hey, don't look at me, I'm just using it ... to be more precise, I'm using something that uses llvm
 
3:36 AM
@RMartinhoFernandes YES!
 
well, turns out linking is broken even with a different file name. This gets odder and odder ...
 
@RMartinhoFernandes voted for reopen
 

« first day (415 days earlier)      last day (4530 days later) »