« first day (605 days earlier)      last day (4329 days later) » 

12:00 PM
@DomagojPandža Still haven't upvoted that one ?! :)
 
Sorry, I was off to the kitchen, forgot about the stove and my food.
Suffice it to say, the stove killed my food.
 
@DomagojPandža So it was alive as you had put it in there ;) ?
 
It was sausaged chicken. :Đ
 
12:24 PM
encode_request *enc_req = (encode_request *)malloc(sizeof(*enc_req)); // encode_request is a structure

whats the better way to do this in C++ ?
encode_request *enc_req = new encode_request; ?
 
4
Q: efficient integer compare function

FredOverflowThe compare function is a function that takes two arguments a and b and returns an integer describing their order. If a is smaller than b, the result is some negative integer. If a is bigger than b, the result is some positive integer. Otherwise, a and b are equal, and the result is zero. This f...

Can someone find a better solution? :)
 
hey fred
you should srsly think about not tagging your questions C++
I'm eternally disappointed every time I click one to find that it's half C, half assembler
 
@FredOverflow Actually, I think that's a pretty good solution.
Is there some reason that you want to return the actual difference as opposed to the cardinality?
 
:-( why nobody answered my question
 
19 hours ago, by Cat Plus Plus
If you are new here, please read the newbie hints and keep the acronym list under your pillow. Also, read this before asking any questions. Thanks.
 
12:33 PM
Look at the first item on the star list on the right side of your screen.
 
@Abhishek Why can't you do it this way?
 
:-|
 
cause he should us std::unique_ptr<encode_request> enc_req instead
who uses new anyways?
 
encode_request *enc_req = (encode_request *)malloc(sizeof(*enc_req));

1 week ago i was told in this chat that malloc is bad
 
@TonyTheLion Nobody with sanity.
 
12:34 PM
true
@Abhishek don't use it in C++
smart pointers
 
thats why i am wondering.
 
I already told you what you should use
 
Ell
how do you not use new? o.O
I understand not using delete, but you have to use new?
 
you use smart pointers and RAII
 
Hmm
ty.
 
12:35 PM
@Abhishek Don't use smart pointers if you don't need to reference them by multiple instances
 
if you're using new you'll end up using delete
 
@DeadMG I just want you guys to find it ;)
 
@FredOverflow But I don't want to find it.
 
Ell
so how do i construct an object in the heap without using new? with a std::unique_ptr for example
 
that's the whole point of featured tags
 
12:36 PM
std::unique_ptr<blah> bla
 
Ell
that constructs it on the heap? woaah I have been wholly mislead
 
in the guts of std::unique_ptr you have a raw pointer
but you don't have to worry about that
 
@Ell No it doesn't.
 
you can deref bla just like a raw pointer
 
the default constructor constructs bla to null
 
Ell
12:37 PM
phew :L
 
the unique_ptr is on the stack/heap as you would expect, the actual calls to new and delete are handled for you. you need never worry your pretty little face about it
 
new and delete are always in the game, sometimes you even have to override default behavior, it's just a matter that the actual developer should be avoiding them in favor of safe things that won't explode. Smart pointers and using RAII to your advantage is a good idea, but doesn't always translate to practice.
 
@Ell You do it by using make_unique, a function template that will be added to the C++ standard library soon ;)
 
Do what you can to be a worthy C++ bacon of vomit.
 
Ell
12:38 PM
but if bla points to null, then surely I have to do .reset(new blah()) or something don't I?
 
the room title is saying bacon as in the tasty tasty pig flesh right?
 
@Neil Where did I say I wanted to return the difference? Returning the difference for characters is just a neat implementation trick.
 
@Ell Right. But instead, you can use make_unique.
 
Ell
so I would go bla = make_unique(blah)?
 
user image
3
bacon :)
 
12:40 PM
Yum.
 
Ell
MyClass() : bla(make_unique(blah)) {};
 
yay! I can read!
 
what? You just learned to read?
 
@FredOverflow You're worried about overflow of ints, but a solution was provided to return the cardinality of the ints rather than their difference return (a < b ? -1 : (a == b ? 0 : 1))
What's wrong with that solution?
 
There should be a website preaching proper C++, with an emphasis on C++11.
A true website to rule them all. And to subdue the evil cplusplus piece of shittery.
 
12:44 PM
@Neil There is nothing wrong with that solution. I'm simply asking if there is a more efficient solution.
 
@DomagojPandža just like this ^
this coffee is staggeringly bad. I have no idea how they get away with this bio weapon
 
@FredOverflow I don't think so. You're doing at most two comparisons, nothing more.
 
I'm not even that fussy with coffee
 
@sehe it's not my fault xkcd is so good
 
12:49 PM
Human inability to see, recognize, adapt and utilize useful new notions is of no consequence. There needs to be a presence of light and utter goodness that is the new C++11 standard. We must banish the unholy Microsoft's offensive to cripple the supply lines of C++11.
The future of our code and the code of our children depends on it.
I must admit, this is a good one.
 
@DomagojPandža I didn't get that. Have there been some famous scientists come from humble beginnings as a swiss patent clerk?
 
@DomagojPandža I see you have fulfilled your duty
@Neil Wasn't Einstein working in a patent office? When he conceived the theory of relativity
 
@Neil I guess you're joking, but - I'll take the bait - Albert Einstein pondered on the nature of light and the problem of the Galilei-Newton relativity (the notion of absolute time was clashing with c being constant for all observers) while he was working in a patent office.
 
@sehe stole you mean :P
 
hehe
@thecoshman Hey, as a patent officer, you can
 
1:00 PM
hi.....everyone, i'm a new on chat. I'm an average c programmer. I want to know how can i increase my skill in programming.
 
20 hours ago, by Cat Plus Plus
If you are new here, please read the newbie hints and keep the acronym list under your pillow. Also, read this before asking any questions. Thanks.
@mschoudhary2000 practice then. Think of a simple project to do, and do it with as many bells and whistles as you can
oh, and by the way, this is a C++ room, not a C room
 
And switch to C++, why torture yourself with C if it isn't necessary (ie. a C++ compiler is unavailable on your platform, an excuse several decades old).
 
would you look at that, I didn't bite some ones head off :D
 
Modern C++ at that, not the Cish excuse for C++
 
I really need to just subscribe to the engineer guy on youtube
 
1:08 PM
@DomagojPandža I honestly thought he was a hotel bag boy or something, or something equally demeaning
 
Hi All.
I am new in C++.Just want to ask some question to you guys.Can I ?
 
@iPhoneDev Certainly. Shoot.
 
Thanks Neil.
 
Why we use Class.As everything can be done in using structure in C++.
?
 
1:14 PM
81
Q: When should you use a class vs a struct in C++?

ZeroSignalIn what scenarios is it better to use a struct vs a class in C++?

 
You can google that easily, @iPhoneDev
 
ok.
 
Traditionally, structs couldn't do everything they can now
 
People here too kind, much too kind.
 
Personally I use classes for entities and structs for values. But that's just me.
 
1:15 PM
ok.
What happen when we use exception on destructor?
 
So that said, there's not a great deal of difference now. Though structs have public accessors as default, meaning structs are meant more for data collections than anything else
 
@iPhoneDev Bad things.
 
Dtors should never throw. Peroid. :)
 
@EtiennedeMartel Indeed. Bad for classes and structs.
 
i want to know if there is really good open source for a newbie like me...
 
1:17 PM
@Neil I know it should not.But what happen.ANy stack winding I found while googling.
 
@iPhoneDev Here's what happens: when you throw an exception, the runtime has to invoke the destructor of any object that's on the stack up to the first matching catch it encounters. That is called "stack unwinding". If one of those destructors throw, then the runtime ends up with two exceptions. What is it gonna do? Well, the standard says it should call terminate, which kills the process.
So, best way to make sure that never happens is to never throw from a destructor.
 
@EtiennedeMartel Which is good if ugly program halting is what you're after.
 
@Neil We don't have the same definition of "good".
 
Now don't you start getting pedantic as well.
 
@EtiennedeMartel If that's what you want, it's good. Maybe he's a hacker. :)
 
1:20 PM
@EtiennedeMartel understood.thanks.
 
@mschoudhary2000 Open source what? Need moar context
 
I still don't get it. I wouldn't mind looking like an asshole saying this but there's a question explaining everything on SO proper and someone comes here and asks the same thing, to which the best reply is simply a link to the SO question the person should have had looked up in the first place.
 
@ScarletAmaranth Yeah, well, I feel nice today.
 
@ScarletAmaranth sorry.But instead of looking books if discuss something I understood bit early.
 
@iPhoneDev He means you could have googled anything you asked here, and the results would probably have contained one or two SO questions.
 
1:24 PM
@iPhoneDev Don't take it personally that I linked to SO, but I think it's necessary to make it clear that this information is already available to you in some form before I answer.
@EtiennedeMartel Mostly anything can be found on google. I won't say everything, but I think you'd be hardpressed *not* to find something if you searched hard enough
 
One more how the copy constructor is recursive.When we pass by value.Because there is no ; where it catch by copy constructor.
@Neil.ok.
 
@iPhoneDev Those are not questions that can be discussed in any way really. Those are questions that have a fairly absolute and short answer and can be looked up easily. It's not arcane knowledge.
 
@iPhoneDev When it must copy by value, it looks for a copy constructor
Not actually sure what happens if there isn't one. It's been too long that I've been a Java programmer that I'm not used to thinking about such things
 
@ScarletAmaranth Sorry.Let other give their response.I have no money to buy book.or use internet evrytime or any institute I can go.Just borrow some momney from my friend and using internet.
 
@iPhoneDev Your argument is invalid. This information can be looked up for free on this very website without asking in the chat
 
1:28 PM
@ScarletAmaranth Well give the poor guy a break. What's Lounge<C++> for if everytime someone asks a question, we point them to google
 
@iPhoneDev I assume you have been linked to our guide lines. Right now, you are very close to being annoying. Helping others is fairly low on the list of reasons why we come to this chat room
 
@Neil We could always just add in an auto redirect to google if the username isn't known.
 
@Neil what's Google for if every time some one has a question, they come here?
 
sorry guys.I will never interfer you agin.So sorry.No matter if I will not get any answer.
 
@thecoshman There should be some balance though, should there not?
@SamDeHaan Good idea for a bot.
 
1:29 PM
@Neil I'm not trying to be an asshole, I'm just wondering what's the point in helping someone who obviously didn't put any effort into trying to understand the matter.
 
Please guys don't argue.i m sorry agin.
with each other.
 
@iPhoneDev feel free to come and chat, but please remember that we are here to chat, and often the best place to get answers is on SO or Google
4
 
@thecoshman Thanks.But if somebody explain the basic.And then if you search then its esy 2 understand.
 
@ScarletAmaranth You could argue that anyone posting on stackoverflow didn't take the time to understand the problem. It's relative.
 
@Neil If he asked those questions on SO, he would have had 50 downvotes already for the duplicates.
 
1:31 PM
Good day folks!
 
XY much?
-1
Q: C++0x lambdas to Function Pointer

Antonio Arruda BassoI'm starting to develop applications using C++0x lambdas, and need to convert some types to function pointers. This works perfectly in GCC 4.6.0: void (* test)() = []() { puts("Test!"); }; teste(); My problem is when I need to use function or method local variables within the lambda: con...

 
lambda with puts(), interesting.
 
@ScarletAmaranth Probably, but then that doesn't encourage such people to search for answers on SO, does it? It probably encourages them to ask in other ways, Lounge<C++> for instance.
 
const char *text :D
 
@iPhoneDev I know what you saying, C++ is a vast subject area and it can be hard to know where to start
 
1:34 PM
@Neil There's a "search field" on SO proper that would show him the thing he was looking for right away. Not to mention uncle google would do the same thing. Oh well, let's just drop this :-)
 
@thecoshman yes
@ScarletAmaranth and @Neil.Please don't argue.
 
I can not use std::function because my code requires RTTI and EXCEPTIONS are disabled. — Antonio Arruda Basso 18 mins ago
What?
 
@ScarletAmaranth I know, but negative reinforcement isn't as effective without being explicitly clear in your intentions.
@iPhoneDev You don't know us very well. This isn't arguing. :)
 
@Neil I'm officially dropping the sodding thing man ;)
 
@ScarletAmaranth Done. Forgotten.
 
1:36 PM
@iPhoneDev that said, the questions I have seen from you so far have seemed like simple things to google, 'struct vs class in C++' 'exceptions in destructors'
 
@EtiennedeMartel "(...) (my code) requires ((RTTI and EXCEPTIONS) are disabled)." Lispified.
 
You are so useful right now.
 
If you can't find it in google, forums, or SO, Lounge<C++> is where you go, not because we offer the best help but because you're desperate. No offense guys.
 
Hh, our sub-par help may sometimes come in handy ^^
 
1:38 PM
A long isn't 4 bytes long.....
 
@RMartinhoFernandes But I don't need Lisp, I don't use emacs. Duh.
 
@Drise why should it be?
 
@Drise It's like saying: "Werediggles gonna werediggle".
 
Because short isn't 2 bytes short.
@ScarletAmaranth "Werediggles gonna weredig". FTFY
 
"You create char temp[5] which then immediately cast it to a long, which is only 4 bytes, and you loose a byte."
 
1:40 PM
@RMartinhoFernandes Ooo, right, sry :P
 
I got this email earlier...
 
@RMartinhoFernandes More like: (require-disabled my-code [RTTI EXCEPTIONS]) :p
Use Clojure syntax which supports [] for lists.
 
@Drise of order mater posts the your
 
Really, std::function uses RTTI?
 
@EtiennedeMartel Likely uses virtual functions inside.
 
1:41 PM
@thecoshman I was thinking out loud lol
 
I wasn't aware that virtual required RTTI support.
 
@StackedCrooked Virtual functions still work without that.
@EtiennedeMartel Only dynamic_cast and typeid.
 
Morning.
 
@Drise talking out loud on the internet makes you seem crazy, even on the internet
 
hello @RadekSlupik
 
1:43 PM
Only dynamic_cast and typeid need RTTI.
virtual just needs a table of function pointers.
 
Should one get into the habit of using std::? it just makes everything so messy...
 
I use it constantly.
 
Yup.
 
@Drise You don't know messy.
 
Without it works until you use a library that defines its own "string" or "vector" class.
 
1:47 PM
@RadekSlupik Thank god I use intelligent libraries, such that QString and vtkVector are not named so similarly.
 
@EtiennedeMartel It's the other way round RTTI needs at least a virtual function
I wish they implemented RTTI completely.
 
@Drise Try using namespace std in your header and:
 
@Drise for the love of all that is good and holy, yes
 
96
Q: Why is 'using namespace std;' considered a bad practice in C++?

ManaOkay, sorry for the simplistic question, but this has been bugging me ever since I finished high school C++ last year. I've been told by others on numerous occasions that my teacher was wrong in saying that we should have using namespace std; in our programs, and that std::cout and std::cin are m...

 
1:48 PM
that's old :)
 
@Drise intelligent? They don't even use a fucking namespace. "I'm a C programmer! I prepend names with my project name; namespaces are useless!"
 
may I suggest we have a link to the C++-faq tag page in the star message we love
 
@RadekSlupik " I prepend names with my project name " o_O ?
 
heh
 
Use a namespace instead.
I'm talking about Qt and all those other crappy C++ libraries. Box2D.
 
1:50 PM
what's crappy about qt?
 
@thecoshman There's one in the topic.
 
Doesn't use namespaces.
Doesn't use STL.
Uses pointers.
 
@RMartinhoFernandes clearly not working :P
 
@RadekSlupik it's old and supports old compilers
@RadekSlupik Last point: Go read the design documents and shut up
 
@Nils It's like they tried to recreate the Java libs, in C++.
 
1:54 PM
@Nils Yes, it's crappy because it's old :P
 
@EtiennedeMartel By far not, the xml lib is a bit Java inspired, so yes.
and QContainers interop nicely with STL containers
 
I dislike cross-platform GUI libraries anyway.
 
Yeah, but why not use the standard containers then?
 
The only useful gui lib I could find for C++.
 
@EtiennedeMartel Because QContainers "have more features".
 
1:55 PM
I would probably rather use Apples iOS libs.
 
(IOW, I don't know the stdlib)
 
Bullshit.
 
Zing
 
Qt is afflicted with a severe case of NIH.
 
Schreeuw
 
1:56 PM
So what do you guys use then?
 
The model–view–controller framework separates the representation of information in a computer program from the user's interaction with it. The model consists of application data and business rules, and the controller mediates input, converting it to commands for the model or view. A view can be any output representation of data, such as a chart or a diagram. Multiple views of the same data are possible, such as a pie chart for management and a tabular view for accountants. See also *Presentation–abstraction–control *Model–view–presenter *Model View ViewModel *Observer pattern References...
 
Instead of extending the standard lib, they just wrote a new one, and decided to extend the language itself with new features.
 
Cocoa.
 
The end result is a fucking mess that I can't bring myself to call "C++".
 
is that theory considered old hat or something?
 
1:57 PM
@EtiennedeMartel They started before the std lib was supported everywhere.
Surely it is not optimal, but probably the best choice for C++ gui IMHO.
 
@EtiennedeMartel NIH?
 
The best choice is to write it yourself.
 
@Nils That's precisely the reason it's crappy, not a get out of jail free card.
@thecoshman Never Inject Heroin.
 
@thecoshman Not Invented Here
 
I'll just leave this here - Springok
 
1:59 PM
@Nils Sure, so they're stuck with an awkward legacy of crap.
 
The problem with Qt (and others) is that they want it to work on multiple completely different platforms. That doesn't work. Idioms, design choices and conventions are different on those platforms.
 
@RMartinhoFernandes I’ve just noticed that you’ve set up your blog with Jekyll/ GitHub Pages … have you thought about implementing comments for it?
 
yes, I agree they have some problems, but what options do you have for C++ gui
 
None. You don't do GUIs in C++.
 
@RadekSlupik It works and works well, and it's cross platform. stop hating so hard
 

« first day (605 days earlier)      last day (4329 days later) »