« first day (596 days earlier)      last day (4343 days later) » 

4:02 PM
@StackedCrooked I wouldn't bother. It's probably a thousand times faster than your own implementation.
The library implementers know what they're doing.
The overhead should be very minimal. And the space on the stack, well, you need to store the size somewhere even when you do it yourself.
 
I don't think allocating memory works faster for them than for me. Unless they got some secret switches.
But the question is because I want to convince my coworkers that std::vector really isn't slower than c-style arrays.
 
std::vector is probably the most used container in all of C++ (maybe after std::string), so it must be fast as hell.
 
There's no overhead. There's only overhead if you want something other than an resizable array with runtime size.
 
I'm almost there, but not yet. Now I hear them saying "Yeah, a vector is about as fast an array, there isn't much difference." I think this indicates that they still have distrust.
 
A vector uses a C-style array internally and function calls such as push_back can get inlined.
Also: show them benchmarks.
 
4:07 PM
tell them about safety
 
@StackedCrooked No difference. End of discussion.
 
user425495
newbie question: what is the difference between f1(const int * const x) and f2(const int & x)
 
user425495
I know you cant pass null to f2
 
@JustinShrake The first one takes a const pointer to a const int, the second one takes a reference to a const int.
@JustinShrake I suggest you read a good book on C++. :)
 
There could be a negligible difference in size if your vector implementation uses two pointers instead of pointer+size, and sizeof(size_t) < sizeof(void*).
 
user425495
4:10 PM
yes but a reference cannot be changed once it is assigned so it is in some sense const
 
1193
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are released every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...

@JustinShrake The reference itself cannot be changed, but the object it references can.
 
user425495
I'm reading Accelerated C++ :)
 
user425495
Yes but you can't change the object if it's a const ref
 
int foo = 42;
int& bar = foo;
bar = 24;
std::cout << foo; // prints 24
However, int const& bar = foo; bar = 24; is invalid.
@JustinShrake that's true.
Same with pointers.
 
Top-level const is irrelevant in arguments.
 
4:13 PM
Think of a pointer as a variable that holds a memory address, and think of a reference as a second name of a variable.
 
@RMartinhoFernandes Except as the argument to decltype (just being asinine)
 
@JustinShrake The object it references is const. References themselves are always immutable.
But the main difference is that the first function you gave doesn't guarantee that a pointer to a valid object is passed in. You can pass nullptr to it, for example. The second function is guaranteed to take a reference to a valid object.
 
user425495
Yes I understand that. I guess I'm trying to make an equivalence between references and const pointers
 
A reference is just a disembodied lvalue. There's no object there to consider mutability.
 
@Potatoswatter No, that's correct.
sizeof(T&) == sizeof(T).
 
user425495
4:17 PM
@RMartinhoFernandes I don't understand your response
 
user425495
Top-level const is irrelevant in arguments.
 
You can declare a function as void f(int*); and then define as void f(int*const) {}.
 
@RadekdaknokSlupik I keep hearing how "safe" references are. It's utter nonsense. References are no safer than pointers. Both will cause trouble if you don't comply with the contract of the function wrt the lifetime of the object passed in.
 
user425495
ah I see
 
@JustinShrake Well, your function takes a const pointer. Since the pointer is passed by value, it doesn't make sense to make it const (unless you want to prevent yourself from modifying the pointer). Note that I'm talking about the pointer itself, not the object that it points to.
 
4:18 PM
@RadekdaknokSlupik Ah, just had to go try and see. That's a bit weird… shouldn't do that.
 
They are safer.
 
They don't encourage folks to try and plug NULL where it don't belong.
 
@BenVoigt Ignoring lifetime, a reference is guaranteed to reference a valid object, assuming there was no UB before (like int* foo = nullptr; int& bar = *foo;).
If you can't get the lifetime of objects right, you just suck.
 
No they aren't. They provide a small hint as to the actual contract of the function, but still are no match for good and complete documentation.
 
@RadekdaknokSlupik You can only get an invalid pointer by threading too close to UB anyway.
 
4:20 PM
References can be assumed to be valid.
 
@RMartinhoFernandes nullptr.
 
@CatPlusPlus Total nonsense.
 
@BenVoigt Explain.
 
@RadekdaknokSlupik Yes, pointers have additional semantics. So what?
 
@RadekdaknokSlupik Dangling references
 
4:21 PM
We can assume anything we like, the mileage may vary ;v)
 
1 min ago, by Radek 'daknok' Slupik
@BenVoigt Ignoring lifetime, a reference is guaranteed to reference a valid object, assuming there was no UB before (like int* foo = nullptr; int& bar = *foo;).
 
@Radek, give me a moment to look up an answer I've already posted, instead of repeating the explanation in chat.
 
Ignoring lifetime
 
Dangling references are created by UB.
 
The whole point is that you CAN'T ignore lifetime, for either references or pointers. And if you pay attention to lifetime, they act the same, with one exception.... lifetime extension for temporary variables (under some circumstances).
 
4:22 PM
Pointer's ain't guaranteed to point to a valid object even without preceding UB, as per nullptr.
 
Ditto references.
UB can create dangling references, but dangling references can be created in many other ways.
 
@BenVoigt No. References must be initialized with a valid object.
 
user425495
What is UB
 
Undefined behavior.
 
undefined behavior
 
4:23 PM
It can order you a pizza, as well as infinite other things. But you don't know what it will do.
 
Anyway, enough with silly C++ talk, time to pewpew something in space.
 
int &not_ub() { int i; return i; }
 
This is UB.
 
@Potatoswatter Lifetime issue.
I was ignoring lifetime issues, as I said.
4 mins ago, by Radek 'daknok' Slupik
If you can't get the lifetime of objects right, you just suck.
 
@CatPlusPlus You mean IN SPACE?
 
4:24 PM
So, ignoring major issues, references are safer. Ok, got it.
3
 
I just don't like pointers.
@EtiennedeMartel In SPACE.
 
@RMartinhoFernandes if those major issues apply to both references and pointers, and references are safer than pointers even without those issues, they are also safer with those issues.
 
References are just as subject to misuse as pointers.
 
@RadekdaknokSlupik If you take a pointer, you usually do so to express optionality.
 
Just satisfy the contract of the function you call, and you're set.
 
4:26 PM
Y'all crazy.
 
@RMartinhoFernandes boost::optional ftw.
 
Like saying T& is safer than optional<T&>. Apples to oranges.
 
@RMartinhoFernandes Or mutability. Look guys, this debate isn't gonna come to a conclusion. Right tool for the job.
 
6
Q: Why is a c++ reference considered safer than a pointer?

yasouserWhen the c++ compiler generates very similar assembler code for a reference and pointer, why is using references preferred (and considered safer) compared to pointers? I did see Difference between pointer variable and reference variable in C++ which discusses the differences between them. E...

 
I'm going to work on Hexapoda.
 
4:35 PM
@CatPlusPlus Oh, shit. You play Eve?
That game for "nerds who are to nerds what nerds are to normal people"?
 
Yes. :(
 
clang y u allow recursive main.
 
Why wouldn't it?
 
Ain't that forbidden in C++?
 
You can't prevent it in general (think function pointers), so they probably didn't think it was worth it.
 
4:40 PM
35
A: Is it legal to recurse into main() in C++?

icecrimeAccording to the standard in 3.6.1/3, it's not : The function main shall not be used (3.2) within a program The definition of used being : An object or non-overloaded function is used if its name appears in a potentially-evaluated expression.

@RMartinhoFernandes You cannot get a pointer to main either.
 
Well, they still thought it wasn't worth it.
Really, who the fuck does that accidentally?
 
I did it on purpose a few times
 
4:58 PM
@RMartinhoFernandes why do you actually have half of your stuff on bitbucket and the other half on github?
 
@bamboon The stuff on GitHub is mostly forks from stuff that was on GitHub. Also, I used to use git before.
The blog is on GitHub because of the Pages functionality they provide.
 
@RMartinhoFernandes ah ok, makes sense.
 
I need to parse Markdown in C++. xD
 
@RadekdaknokSlupik Good luck if there’s no library. Markdown is a bitch to parse correctly
 
Discount.
 
5:04 PM
so how long do you think it will take to analyze 6500 propagations into my 114600 size tree
 
18
Q: Markdown Implementations for C/C++

Kristopher JohnsonWhat is the best implementation of Markdown for C or C++? I found these via Google, and would appreciate comments about which ones work well and which ones don't (and which ones I may have missed): peg-markdown Discount Cpp-Markdown libupskirt

 
even concurrently this is going to take forever
 
Still trying to break SHA-2?
 
yes
 
You're really bored.
 
5:06 PM
I believe that it's time to add in new information and I'm going to run a greedy search to find out which bit is the best
but propagating knowledge through the very giant tree takes some time
mb I need to hand-roll RTTI again to get things going a little faster
oh and then it crashed
lol
 
> It is written by hardcore C programmer and quite hardly maintainable.
Advantages — Written in pure C.
 
That is an advantage.
Has high interoperability and little dependencies.
 
C libraries can have decent API.
 
Last time I check it it had only a FILE API. Seems fixed now. :D
 
5:20 PM
note to self
you cannot gain 0 bits of information by adding in at least one bit of inormation
also, it's probably more effective to use the O(1) check rather than the O(N) check
also fuuuu ICE :(
 
5:34 PM
Ice is cool.
 
C++11 y u no named arguments
 
std::map! :P
/* comments */! :P
 
also, y did I no use a function instead of copying and pasting everywhere the first time
 
5:51 PM
lol
 
Map is a poor substitute for real named arguments.
Even with brace initialisation.
 
Map sucks for named arguments.
 
@CatPlusPlus there is always Boost Parameters, or my own Options class. or just plain Named Parameters Idiom
 
I know, I've used Parameters before. Those specifications are crazy to write.
 
hmmmmmm
pass 10000 to hash map initializer, CRT fails because the value is 5 billion
 
5:54 PM
Anyone know of a tool to automatically put all my code in namespace? I have many source files and it's boring to do manually.
 
Ruby uses hashmaps everywhere for named arguments.
They failed to copy that part of Python core.
 
@StackedCrooked just script it. like, python
 
Perhaps a Vim macro could work.
 
^ Easier to use. :-) But hell to fix all that spaghetti "back end" template code. :-(
 
Yeah, I know that, too. I've used it recently for my window request thingy.
 
6:02 PM
hm, it's late, time to make dinner
 
Job done. Vim rocks!
2
I do need to make a few corrections though.
 
hmmm
y does vector in unordered map internals throw random length_error
 
@StackedCrooked that was fast, learning lisp and creating macro and doing all that stuff in just ... minutes?
 
man
y is there spider in my room
 
it has to do with the length_error
 
6:05 PM
@CheersandhthAlf Vim, not emacs.
 
@CheersandhthAlf I have played with macros a lot. It doesn't involve any lisp or anything. Just a littlle bit of creativity.
 
well what's in vim then?
ecmascript?
 
YSOD on SO
 
Just type qq and do the actions you want saved. Press q again at the end. Then you type @q to repeat it.
 
6:06 PM
hm
 
@CheersandhthAlf They have their custom macro language. It sucks.
(but recorded macros are something else anyway)
 
@KonradRudolph Oh noes!
 
> Server Error in '/' Application.
SO is down?
 
Vimscript isn't your only choice in Vim.
 
@CatPlusPlus True
 
6:08 PM
@Pubby Stupidity overflow.
 
I opened a file which contained a list of all my source files. Then I moved the cursor to the top left of the file and recorded my macro as follows: Duplicate current tab. Open the file under cursor. Go to bottom of file. Search for #include upwards. Insert text below for opening namespace. Go to bottom of file. Insert new line above the current one and put text for closing namespace. Close current file. Move cursor one line down. End of macro. Repeat baby!
It's just a series of commands.
 
Chat's working, so who cares.
 
And repeating can be done like 17@q to do it 17 times at once, which is the awesomez.
 
It failed for files that didn't include any headers. It stopped the macro from continuing. So I had to restart a few times.
 
hm
SO is #5 on HN
just because it’s down
 
6:12 PM
Isupagain.
Oh, finally new Haskell Platform.
I've waited whole damn May for this. Silly people, don't put up "May" as release date when you're releasing it at the very end.
 
I struggle to define this as "May"
in fact, if I had to define "Not May", then "June" probably works
 
If I do cout << std::hex then I need to put it back to std::dec for the next time. Is there a RAII-like approach to do this?
 
There's one in boost.
 
Perhaps I should just always specify the desired format.
 
Use Boost.Format or FastFormat for formatting.
Streams suck at this.
 
6:19 PM
hmmm
it's probably a bad sign when you change your allocator and suddenly constants fold more than they did before, right?
 
Lol.
Wee, GHC 7.4.
 
Oh god, the interview guy is back.
0
Q: Can a template function be called with missing template parameters in C++ ?

user1002288This is an interview question, which has been done. Which line has error ? #include<iostream> template<class T> void foo(T op1, T op2) { std::cout << "op1=" << op1 << std::endl; std::cout << "op2=" << op2 << std::endl; } t...

 
Xeo
Huzzah, I am awake!
 
@Xeo Congrats.
 
Yeah! Good job Xeo!
 
6:23 PM
I posted a comment which I believe to be quite representative of us as a room
 
Xeo
Thanks! Quite the feat, if I may say so myself.
 
I like the interview guy. You are not representing me fairly.
 
Puppy says how it is.
 
Oh look, rocks.
 
6:24 PM
^ on mars!
it's the sphinx nose, and a saucer craft!
 
hmmmm
 
apparently, I can gain 18446744073709551525 bits of information by setting one bit
this I find somewhat unlikely
 
hola!
 
Xeo
6:26 PM
@DeadMG Your code is just surprising you! It had that information all along, but waited for the right moment to present it to you.
 
there are only 119,000 bits of information to be had.
 
@Xeo Are you sure you're awake?
 
Xeo
@RMartinhoFernandes Aye
 
although I'm so glad that I implemented all those optimizations
 
Xeo
Physically awake, anyways.
 
6:27 PM
now it doesn't take quite so cockingly long to execute
 
@Xeo Or are you? Dunn, dunnnn, dunnnnnnn.
 
Xeo
So my maybe-dream's telling me I may be dreaming?
 
I want embeddable Haskell VM for C++.
> The Language.Haskell.TH.Syntax.Quasi class now has a qAddDependentFile method, which splices can use to indicate that the result of the splice depends upon the contents of a file. This tells the compiler that if the file has changed then it will need to recompile the module containing the splice.
In-language code generation done right, right there.
 
hmm
 
Holy raspberries, that is nice.
 
6:37 PM
so if I have a && b = c1 and a ^ b = c2, I can prove a value for b, and by extension a, given c1 and c2 unless c1 is 0 and c2 is 1.
not sure if good
 
@KillianDS =) I guess I'll have to google it!
 
yum
Chicken Tandoori with roast veggies
 
6:54 PM
oooh, I found a pretty pattern
hmm
91 bits for setting the value of one individual bit?
that sound like a lot?
 
7:13 PM
 
7:27 PM
user image
2
 
@CatPlusPlus My new background ;)
 
If anyone ever doubts why Haskell > C++, Haskell has a logo and C++ doesn't.
 
My wallpaper is fine.
GraphViz y u lines over text.
Pics or it didn't happen.
Nice.
Has anybody here used OmniGraffle?
 
Used it once or twice.
 
well, I just bought the Indie Bundle
 
7:35 PM
Excellent.
 
OK, the previous bundles, I wasn't that interested
but Steam keys? GIEF NAO
 
IIRC, Steam keys have always been part of the Bundles.
@ScottW You might need to get it.
Otherwise your balls might just fall off.
 
I paid a whole one cent over the average
now I don't feel bad
IMO, their "over the average" thing is a good system
the average is just gonna go up and up asthe sale goes on
 
I paid 25$ because I don't know what to do with my disposable income.
 
well
quite fortunately, I'm sitting here downloading Bastion at 3.8MB/s, so I'm gonna be playing sooner rather than later
 
7:41 PM
guys, standard n3376(24.5.12) first page bottom line, is this a joke or just a fail?
 
24.5.12?
 
@sehe date
but it is obviously a joke
 
Oh, like that
> Note: this is an early draft. It’s known to be incomplet and incorrekt, and it has lots of bad formatting.
 
didn't know the standard was full of jokes
 
it's for pete's sake
 
7:45 PM
It isn't full of it
(pun intended)
@CheersandhthAlf Zing
 
Steam keys were offered by HIB since HIB2.
(And HIB1 keys were later included in HIB2.)
room topic changed to Lounge<C++>: Almost, but not quite, entirely unlike C. [c++] [c++11] [c++-faq]
 
Hey shouldn't there be more abstract factories in this design?
 
Where the fuck does that come from?
 
Wow, selecting a type to inherit from based on whether a typedef exist in the provided template argument is a very nice way of overriding behavior without the clumsiness of many parameters.
 
@EtiennedeMartel The Internet.
 
7:49 PM
No shit.
 
I had to read that twice.
 
@StackedCrooked That's a mouthful.
 
I based it on the Wikipedia article on SFINAE.
@EtiennedeMartel Been coding for way too long. Should stop now :p
 
Drink beer instead.
 
I'll do that.
That doesn't necessarily stop me from coding though.
 
7:56 PM
Indeed.
 
But I'm happy with my discovery. It could greatly simplify things. (Despite looking awefully complex on first sight.)
 
MACROES.
EVUL MACROES.
 
I LIKE!
They look less intimidating than a maze of < <T > U::G>
 
(You probably won't get the pun)
 
Fish.
 
7:58 PM
It's a fish.
 
Trout?
Salmon?
 
En French, we call those "maquereau".
 
I don't like fishes.
 
It's pronounced exactly like macro.
 
In Dutch it's makreel I think.
 
7:59 PM
Yep.
 
Still don't get the pun. It's a nice fish though.
 
So now, when you write a macro, think about this silly fish, and ask yourself "Do I really want a fish in my code?"
 

« first day (596 days earlier)      last day (4343 days later) »