« first day (598 days earlier)      last day (4576 days later) » 

19:00
-2
Q: Motivations to use C (C++) when i can use C++ (C)

NickBeing new to the world of programming, I would ask those who are more experienced than me if there are specific reasons to use the C (C++) programming language when i can use C++ (C).

Pure gold.
@RMartinhoFernandes got it, I get it
An asignee, that is somebody who is assigned, right?
Also hello.
@MooingDuck Ah, well. I wrote it anyway :S ideone.com/ej8Ix
@DomagojPandža Downvote parade?
19:05
-8
dang, that thing is a downvote parade
In fact, that can be done with next_codepoint having only one argument, because I test the stream for the end before (last is only used on the asserts).
That shit cracks me up
Ouch, -10
posted on June 05, 2012 by Herb Sutter

The solution to GotW #104 is now live. Filed under: C++, GotW

Do questions auto-delete when they reach a certain level of downvotes?
I think I remember reading that somewhere
19:07
@RMartinhoFernandes You appear to de-reference the same input iterator twice. Is that even legal? I thought they could only be de-referenced once.
@Drise they auto delete after a certain time with certain conditions
Though that would be easily solvable anyway.
26
A: Auto-deleting old, unanswered zero-score questions after a year?

Jeff AtwoodJust to formally document the exact policies we have in place to remove old abandoned / dead questions: If the question is more than 30 days old, and ... has -1 or lower score has no answers is not locked ... it will be automatically deleted. If the question is more than 365 days old, and ....

@RMartinhoFernandes yeah, that design works, it's just irksome since should_read_one_more has almost the same logic as codepoint_from for each of the unicode encodings.
19:09
@MooingDuck If you also pass the number of code units read (i) into codepoint_from it can help.
The equality logic is bad, though. Apparently non-end-iterators from the same stream should be equal...
Thanks @awoodland
Hey, I answered GOTW#105 on SO the other day!
Herb is stalking me.
Time to pass out for a while, be good, kids. Don't set any trolls on fire while I'm gone.
@RMartinhoFernandes Where?
14
A: Passing smart pointers as arguments

R. Martinho Fernandes I want to pass a shared pointer to a function. Tell me how to do that. I can only think of two reasons to take a shared_ptr argument: The function wants to share ownership of the object; The function does some operation that works specifically on shared_ptrs. Which one are you interested...

19:12
@RMartinhoFernandes wouldn't simply comparing is have the right semantics, since each istream_unicode_iterator represents an iterator at the stream's current position, and you can't have a stream iterator in any other position (besides end which you already handle)?
@StackedCrooked Doesn't cover everything, but most of it.
@DomagojPandža Best comment: Perhaps he's talking about calling a function and passing itself incremented as a parameter C(C++) versus passing itself as a parameter into itself incremented C++(C). Yes, that must be it.
@MooingDuck Yes, is == that.is is ok. I thought only end iterators were equatable, and that's why I wrote it as I did.
Question. In C++03, if I have a struct that contains only a bunch of ints and has no user defined constructors, and I do vector<my_struct> v(200, my_struct()), the ints won't be zero-inited, right?
@EtiennedeMartel think so. Sounds sane enough to me.
19:15
@EtiennedeMartel I think my_struct() will be zero-initialized (due to POD rules with the parenthesis) and they will be zeroinit. I'm very unsure
I think we should get an ideone project going and verify.
@Drise or better yet, check the spec
posted on June 05, 2012 by Herb Sutter

JG Question 1. What are the performance and correctness implications of the following function declaration? Explain.   Guru Question 2. A colleague is writing a function f that takes an existing object of type widget as a required input-only parameter, and trying to decide among the following basic ways to take the parameter (omitting const): [...]

@EtiennedeMartel @MooingDuck ideone.com/LPuAN .Its showing 0's
@Drise Yeah, but that might be UB.
19:22
@Feeds the last two of the guru bit is tricky
@EtiennedeMartel Yes, true. But atleast its a start?
@EtiennedeMartel I think they will be in C++03 but not in C++98
Trolling Rule #1: If you're gonna be a dick, you better be funny!
3
> The implicitly-defined default constructor performs the set of initializations of the class that would be performed by a user-written default constructor for that class with no ctor-initializer (12.6.2) and an empty compound-statement.
So, does it means it initializes PODs?
19:26
@MooingDuck Is that why it printed 0's?
@Drise I'm trying to figure out what happens to members given an empty initializer list. That quote was just the first half
GCC is known to follow the C++03 rules for this, if it helps.
Ell
Ell
hi guys
some_pod() zero-initializes.
@EtiennedeMartel I can't find the wording, but It has to call the default constructor
19:29
@MooingDuck No, it doesn't.
it value-initializes, which means default constructor if one exists, else zero initialization
@MooingDuck §8.5/5 and on, then §8.5/10.
@Ell I'll recognize your presence, since no one else seems to care enough to. Good day indeed!
Ell
Ell
anyone have any idea how to std::fill a boost::multi_array?
@Drise thank you :)
@Ell You're very much welcome, naturally.
@Drise Hey, where I come from "some_pod() zero-initializes" is a greeting.
19:32
@Ell You missed out on a fun downvote parade. stackoverflow.com/q/10903213/868546
Which, btw, is now at -14
And somehow a 1 rep user answered the question after it was closed? What's up with that?
Ell
Ell
yeah I was wondering that
@Drise There's a short window of tolerance if you start writing the answer before it closes.
@RMartinhoFernandes Closed 33 minutes ago, but answered 21 minutes ago. 12 minutes of short tolerance?
SO is not racist.
@RMartinhoFernandes +1'd your answer on gotw :)
19:34
@Drise I've gone a lot longer. AFAIK, the tolerance is infinite.
@StackedCrooked You can +1 stuff there? Wow.
8
Q: Question Answered After it was Closed?

John Saundershttp://stackoverflow.com/questions/2750866/what-should-i-do-from-here-closed was closed at 2010-05-01 18:08:48Z, but was answered at 18:19:38Z (http://stackoverflow.com/questions/2750866/what-should-i-do-from-here/2751048#2751048). How'd that happen?

@RMartinhoFernandes Fair enough.
@StackedCrooked Not here.
Not that I can tell @StackedCrooked
19:39
lol
It is on the first comment.
I bet he did that just to get noticed.
@Drise Normally, but not this time. Ok partly.
stackedcrookedCrooked here.
lol
StakidCrookid?
Sta kid. Crook id.
19:43
@StackedCrooked Oh, on the Mill it is.
> If it is passed by reference, the function will have no choice but to make a copy. If it is passed by value the compiler will pick the best choice between a copy and a move and perform it automatically. So, pass by value.
Really?
Wait, I thought by ref just gave you the address?
Passing a shared_ptr by reference results in a copy?
@StackedCrooked Context.
How do you share ownership with shared_ptr?

By copying it.

Then the function will need to make a copy of a shared_ptr, correct?

Obviously. Does that mean I'll pass it by a reference to const to make the copy?
The function's functionality involves making a copy.
I'm arguing for letting the compiler do the copy, instead of doing it by hand, because the compiler can do a move if the situation presents itself.
@RMartinhoFernandes Or ellision.
19:46
Exactly.
We must be the biggest C++ fans in the world answering this question so quickly.
If you take a const& you're stuck with making a copy by hand always.
How long have you guys been programming? What you're talking about is way out of my league (of knowledge)...
These guys are nuts.
These guys don't program they just study the spec.
:p
19:47
No wonder I can't answer any questions; I'm trying to compete with them...
@Drise Programming in general? Thirteen years. C++? About thirteen months.
I've learned as much in the 2 years I've been on SO than in the 5 years of programming experience before than.
welcome to Lounge<C++>, the place where you quickly realize how stupid you really are!
For real @tony
@Drise ~4 years professionally
19:49
@TonyTheLion I'd put that in the topic, but it would look smug.
lol
I've been doing C++ for like a year
learned from a book and the rest on this chat:P
Welcome to Lounge<C++>! Expect to feel stupid.
3 for me, but no where near as advanced as what you guys regularly discuss...
I've learned much just from hanging out here.
19:50
2.5 years in college and 6 months developing for IERUS tech
@RMartinhoFernandes i"m not sure I understand what you mean?
Seems my 2.5 years of college is proving quite useless. I could have just gotten it free on chat.so lol
@TonyTheLion Ok, lemme fake up an example.
You all should start charging lol.
haha, that's why I skipped college and came straight here :P
19:52
However, practical experience is very valuable. But less quantifiable.
Unfortunately in my work environment, degrees are very requiried.
class foo {
    shared_ptr<T> m; // a member with shared ownership
public:
    void set_member(shared_ptr<T> const& p) {
        // Let's shared ownership of p by copying it
        p = m;
    }
};

foo f;
auto p1 = make_shared<T>(blah);
f.set_member(p1);
f.set_member(make_shared<T>(blah));
@RMartinhoFernandes you only program in C++ for 13 months?
@TonyTheLion The last call passes an rvalue into the function. However, since the function takes a const&, the p = m; will always be a copy and never a move.
or an ellision
19:57
Right :)
Now, if you change it to void set_member(shared_ptr<T> p) { p = std::move(m); }, the last call will cause at most two moves, never a copy.
lol @Radek
Ooh eeh ooh ha ha ting tang walla walla bing bang.
TIL: I'm funny.
19:59
I feel like I should link to "Want Speed? Pass Value" in the answer. This thing is explained there...
If not c++, what language do you enjoy the most? And a reason if you feel so compelled.
@bamboon Start last April, I think.
I gave up on Java due to XML configuration files.
Wait, that makes it fourteen months. Bad brain.
20:00
I'm going to rewrite Hexapoda in Ruby.
JAVA IS A PIECE OF SHIT.
This time I have a good setup.
Ell
Ell
ruby <3
Writes in Ruby. Wants to learn Java. Rewrites in Java. JAVA IS A PIECE OF SHIT. Rewrites in Ruby.
2
@RMartinhoFernandes ah I see, in that context
20:01
Ruby is nice.
@RMartinhoFernandes Well, sometimes you gotta learn it the hard way.
Ell
Ell
speaking of hard.
Not me. At least not now.
@Ell not this again ;)
20:02
@RMartinhoFernandes oh now that makes me feel bad
@RMartinhoFernandes Now I know you're just obsessed.
In Java, setting up a request handler requires a subclass of AbstractController and a method with an annotation.
@bamboon Oh, don't. That makes me sad. I prefer to think I'm exceptional than to have others think they suck by comparing themselves to me.
@RadekdaknokSlupik Sorry what was that ? I stopped reading after : "In java, "
In Ruby it's just get '/path/?' { "hello" } and everything just works.
20:03
You know, from your answers and comments on SO, a fair number of y'all come off as snobby stuck up pricks. But y'all actually are a pretty cool bunch. I like.
6
Ell
Ell
@Drise I don't! :D I look like a noob :P I am a noob
@RadekdaknokSlupik Sorry what was that ? I stopped reading after: "In Ruby, "
@RMartinhoFernandes harhar, that's the other way of looking at it
does it look like a deadlock could happen in the code in this question?
0
Q: boost failing to obtain lock

Potney SwittersI am working on a real-time music application. Working with boost library as a newbie. I implemented a Producer/Consumer relationship with a protected SyncronizedQueue, actually I implemented the 18.11 and 18.12 sections of https://www.quantnet.com/cplusplus-multithreading-boost/. When parsing t...

20:05
@Drise Really? I thought only @DeadMG was a snob.
@Ell I think the general idea is if we hang here long enough we will become non noobish
if you look at his enqeue and dequeue functions
@EtiennedeMartel I thought only @DeadMG was a prick.
@ScarletAmaranth it's just get '/path/?' { "hello" } and everything just works.
In Ruby.
@RMartinhoFernandes He's sausage shaped.
20:05
@TonyTheLion Ah! goto!
really, we come off as snobs?
Ell
Ell
Arhh I wish the debugger worked, I'm having to butcher together a load of std::cout << and std::terminate's
Tony, Y U NO WARN TO WEAR GOGGLES.
Ell
Ell
@TonyTheLion @DeadMG is certainly a snob
...oops ;)
@RadekdaknokSlupik Yeah I know, ruby's actually pretty pewpew :)
20:06
@RMartinhoFernandes damn, I completely missed the goto
@TonyTheLion HOLY MOLY THERE'S A GOTO!
GOTO?!?! Where?!?!
No really, where?
y u all so mean to me :(
Lol!
Facebook? Go face book and study!
20:08
It's funny how many people there are here that don't say anything.
Well @DeadMG Y U NO EXCEPTION/MEMORY SAFE?
@StackedCrooked Seen the latest epis. yet ?
@Drise Was entirely accurate. Some moron wrote "example" code that was of shitty quality, teaching the poor questioner shitty practices.
@DeadMG We're only making fun of you because we love you. Right, guys?
3
@ScarletAmaranth Wow! I forgot!
20:08
@StackedCrooked Just how dare you! :)
@DeadMG Maybe, but I don't like caps. I hated a little, I must admit.
Someone's been posting Bra*nfuck all over the PHP room. Flags ensue.
3
@Drise Teach other people shit -> get what you deserve.
@StackedCrooked hacking away and watching tv, thats why
20:09
@ScarletAmaranth I'll make up for it. I also have to see the next episode of Fate/Zero. Yay!
Wait, not bra*nfuck. If it were bra*nfuck it'd be full of infinite cycles.
lol
@DeadMG Why would you ever want a member function for shit, called get?
@RMartinhoFernandes Indeed, lol
Personally, I think a refactoring is in order. shit->leave(bool onBossDesk);
@Drise Not at all funny.
20:11
oh someone is challenging the puppy
I guess they don't know what's coming :P
@DeadMG Y U RUIN FUN?
@RMartinhoFernandes Yep.
@Drise What fun?
Oh lord, look what I've done now. Pardon my behavior, I don't know what came over me.
1
Q: Please thaw the Sandbox

R. Martinho FernandesThe chat Sandbox has been frozen for inactivity. This is most annoying because we can't send people there to play with the system without annoying everyone else in some other room. In other words, this disrupts the general procrastination routine of people in chat. I thought about creating a new...

20:16
Subtle.
@DeadMG Its a classic: The boss forcing you to do a completely unmotivated refactoring of a codebase just to be WebScale or 2.0 or whatever, Drise's member for poop, maybe a candidate for the single-responsibility principle but, hit that nail square on the head.
@CaptainGiraffe Thanks for the laugh and continuing where I could no longer go.
@Drise I'll be here most of the evening, please don't forget the tip jar. =)
my brain, it is caked in concrete
My brain hurts.
20:21
std::brain or boost::brain?
It keeps telling me to commit some form of ritual suicide (I'm partial to seppuku) after looking at my coworker's code.
@Drise no, thats the reason the needed the volatile keyword.
Ok, I have to be honest. You completely lost me.
@Drise It is a meandering path we wander, turns and twistes, nooks and crannies. But that just makes the path ahead so much more rewarding.
I..... think I'm just going to go sit down.
Pardon me while I empty the contents of my stomach through my mouth all over the floor.
20:25
@Drise Thats good, compacting stack space.
Ell
Ell
aghh my mind has gone blank, I can't even get the expression for pixel -> tile width!
Has anyone else ever met someone who couldn't seem to write... Java?
@CaptainGiraffe Another laugh out loud incident where my co-workers are giving me strange looks.
I don't know java, if that's at all useful @Sam.
@SamDeHaan I don't know anybody thats writes it for fun, and those that work with it rarely talk about it.
Ell
Ell
I'm sorry to do this, but can someone just fix this please! Assume height of tile is 32. With a height of 2 it should give 1, height of 32 it should give 1, height of 33 it should give 2, etc.

(height + (TileHeight - (height % TileHeight))) / TileHeight;
20:28
What is TileWidth doing in there?
Ell
Ell
oops, thats meant to be height
(height / TILE_HEIGHT) + 1
?
@Ell Are you sure 32 shouldn't yield 0?
@Ell Please post the link to the Q instead.
@Collin Doesn't work for 2.
20:28
er
Ell
Ell
@CaptainGiraffe It's not worthy of a question is it? It's barely programming related?
@Ell Try it, you'll never know. We might be a friendly upvoting bunch here. Just make sure you format it nicely.
shouldn't you use ceil?
I second @CaptainGiraffe.
@Ell Just divide the height and take the ceil
Ell
Ell
never thought of ceil
I'm so stupid :P
tiles = height / TILE_HEIGHT
if(height % TILE_HEIGHT) tiles+=1
assuming all those things are integers
20:31
Anybody try PhoneGap? impressions?
@Ell I just solved a similar problem, so it's pretty fresh. stackoverflow.com/q/10743840/868546
@Ell (tileheight + 1) % 32
Ell
Ell
@DeadMG for some reason that just blew my mind o.O
because I'm that good
@DeadMG gah, there it is
Assuming 0 should yield 1, not 0.
20:35
@Ell You can complete this yourself by just giving good names to your constructs. Don't dismiss the intermediaries. Also 0 as the first one makes it a lot easier.
I'm too sexy for my shirt
@DeadMG How much for your shirt?
@CaptainGiraffe 9999999999999999999999999999999999999999 Zimbabwe Dollars
so about £5
Any users of VTK?
Ell
Ell
@DeadMG I actually have some 30 trillion zimbabwe dollars upstairs
zimbabwean currency has all been completely devalued now
20:38
@Ell Dead's estimate of his shirt seems about right to me in Zim dollars.
what was the deal with that rumour about Mugabe being made some UN envoy on tourism?
@awoodland sause?
2 Feb 2009 USD -> ZD 300 000 000 000 000:1
The Zimbabwean dollar (sign: $, or Z$ to distinguish it from other dollar-denominated currencies) was the official currency of Zimbabwe from 1980 to 12 April 2009. Although the dollar was considered to be among the highest-valued currency units when it was introduced in 1980 to replace the Rhodesian dollar at par, political turmoil and hyperinflation rapidly eroded the value of the Zimbabwe dollar to become one of the least valued currency units in the world, undergoing three redenominations, with high face value paper denominations including a $100 trillion banknote (1014). The thi...
@Drise Yep, MG was off by just a few figures. He should be very successful in a career in economics.
@DeadMG Doesn't work for 2!
20:41
That really sucks if you had worked your whole life and saved and shit and now it's more useful to burn than to use as an actual form of exchange.
I noticed lol
@Drise fixed
New zealand?
@Drise oops
Ell
Ell
20:43
I think I'll just use ceil
@Drise I saw a chart and assumed it was right
What in the world is this?
@Ell See my question that I linked.
@Drise a compressed, and minified javascript, I suspect.
best beer I have ever had
if ever I have to drown in something, I want it to be this beer
@CaptainGiraffe Never heard of it.
20:46
@thecoshman I have to try it. Where can I get it?
@thecoshman It's alright, but I prefer ESB.
if you ever see in the shops, BUY IT
@CaptainGiraffe google.co.uk/search?q=mugabe+tourism - if your results look anything like mine
@CaptainGiraffe supermarkets
never seen it in a pub
@CaptainGiraffe I know Tesco's in Ireland have
20:46
@Node I have ESB in local pubs but not this sorcery!
@Node who's it buy? I doubt it can beat this
assert(beer == "horse piss");
@thecoshman So I need to go to ireland for my summer vacation?
@Drise how very dare you
Who flagged this?
20:47
@Drise lol, some douche flagged this.
@Drise If you seriously think that, it means you only tasted crappy beer.
@CaptainGiraffe well, that's another point entirely
@thecoshman Fullers
Budweiser isn't beer, for instance.
> Innis & Gunn is a specialist independent brewing company based in Edinburgh, Scotland. Established in 2003, its beer has gone on to be the most popular British bottled beer sold in Canada, and second most popular in Sweden.
@RMartinhoFernandes that got invalidated pretty quickly
20:48
@EtiennedeMartel Hes an american lad, pleasy forgive him =)
most popular British beer sold in Canada
@RMartinhoFernandes What are you talking about?
I never heard of this.
@EtiennedeMartel I was deeply offended
20:48
@Drise Assertion 'beer == "horse piss"' failed.
@CaptainGiraffe I actually had a good american 'craft' beer the other day, no shit!
I'm feel like a kid saying: "I want to see the flags too!". But I'll suspect that I'll get tired of it once I reach 10k (in a year or two/three).
@EtiennedeMartel get some!
@thecoshman If @EtiennedeMartel is right, which is highly likely, then my assertion is false.
@thecoshman I kid you not, the are micros over there making really good stuff.
20:49
it's something like $ euro for a 330ml bottle, but every drop is worth it
@Drise Honestly, what kinds of beer have you tasted in your life?
I sometimes contemplate the quality of my code... And then I visit SO. All my doubts go away...
5
@thecoshman there are some good micro breweries over there, but they don't sponsor the super bowl
@DomagojPandža Thats why we come here, good or worse
@EtiennedeMartel I don't know what you are talking about. See also: stackoverflow.com/users/868546/drise
20:50
@Drise you live in america?
@thecoshman See above.
:D
@Drise wasn't sure if you where just american or still stuck living there
Alabama. Which means pretty much any stuff brewed by Anheuser-Busch. Which means crap.
19 alabama, all your faults are forgiven.
Luckily I did not grow up here.
20:51
general rule with beer, if you can buy it in most pubs, it's probably not that good
I also live in the northest part of the south, Huntsville.
I'm so going to invent WebScale 2.0 next week
@thecoshman It's a very odd rule but it works.
@thecoshman hipster
@CaptainGiraffe it may be odd, but's true
20:52
@awoodland Sweet, when is the IPO?
@thecoshman Depends. I'd say it mostly goes with how big the brewery is.
Huntsville, Al != Alabama stereotype
@EtiennedeMartel thus, if you can buy it in most pubs :P
People don't usually void*&, but when they do... It's on SO.
2
@StackedCrooked it's true though
20:53
Most of us around here are engineers and scientists for DoD
@thecoshman In Quebec we have quite a bunch of microbreweries.
@DomagojPandža That got me snickering =)
Local Supermarkets are having some sort of fancy beer showdown, I am having the tastiest time of my life
@DomagojPandža I think I get that, but mind explaining?
@Drise Dead on Delivery?
20:54
One of the SO questions... I don't want to talk about it, it's too painful. :Đ
@CaptainGiraffe Department of Defense
but going back to this beer, MY GOD IS IT GOOD!
I've never tasted something so awesome!
@Drise oh sry, Swedish guy here.
@CaptainGiraffe Its all good.
My standard issue beer is this.
20:55
I want to drink red-ish beer too.
@thecoshman If you have a night of drinking, how many of these magical containers would you consume?
I normally fall back on Guniess when going out, it's the closet thing to a decent drink
Guiness is low end dark beer.
@thecoshman So stopping at 3 guiness for 2 more?
Dark beers lead to painful hangovers though.
20:56
@CaptainGiraffe As I said before, we tend to be the most intelligent people within like... well, a lot of kilometers (as a courtesy to our European viewers).
@CaptainGiraffe This bottle of Innis & Gunn was a Christmas present I have been saving, But having had it now, I think I might need to stock up
@Drise You are a localized version of Austin to Texas?
Um... Maybe?
The G is a nice fall back stout, but it's not all that, hell, I'd say even Murphys is a better stout
@CaptainGiraffe ~9 pints probably before moving on to spirits.
20:58
and no, it does not taste any better in Ireland
@Node That would be a heavy night, even by my standards
@StackedCrooked You're just not drinking it right :P
A cool thing though is a black velvet.
Also note: Age of majority in AL is 19 D:
@Drise Just kidding with the TX stereotype. And of course the Alabama one. Thanks for playing along.
20:59
I've gone on Guniess benders, never get a hang over. but lord does it do something sinful with your farts!
Any beer, when consumed in hellish amounts, will wreck your digestive system.
Causing you to kill anything on the next day with your farts.

« first day (598 days earlier)      last day (4576 days later) »