« first day (444 days earlier)      last day (4489 days later) » 

3:01 PM
@sehe sorry about that. I'll try to fix that. Will also upload the .sln file
 
1
Q: How to generate 'consecutive' c++ strings ?

PatrykI would like to generate consecutive c++ strings like e.g. in cameras: IMG001, IMG002 etc. being able to indicate the prefix and the string length. I have found a solution where I can generate random strings from concrete character set : link But I cannot find the thing I want to achieve. Can ...

Watchya think of mine version?
 
@sehe how can I fix inconsistent line endings?
 
Use a decent editor.
 
@sehe are you viewing revision 11 or 10?
check test2.cs, I haven't recompiled test.cs in revision 11.
 
@Eloff You don't like private variables, srsly?
If learning C before C++ is such a bad idea (which I believe it is), why did Bjarne base C++ on C in the first place? :)
 
Xeo
3:15 PM
@FredOverflow Popularity! He just wanted C++ to be popular too. :P
 
@FredOverflow, I do mostly Python programming, where we don't have private variables (well we do sort of, but they're frowned upon.) The logic is that private variables are marked by naming convention, but we're all consenting adults - if someone wants to modify a private variable, we assume he has a pretty damn good reason for it. Enforced private variables is another form of a class designer stating that he knows more about how you will use that class than you do. It's arrogant and incorrect.
 
So you don't believe in abstract data types?
 
I prefer abstract by convention rather than abstract by compiler enforcement
 
@Eloff You know, You're the 3rd Python developer I've seen saying this.
 
@Intermediate haha, it gives us a different perspective I guess
usually using the private methods or variables of a class is a horrible idea though, but occasionally there are situations where the alternatives are worse (e.g. re-implement everything yourself)
 
3:25 PM
What would RAII look like in assembly? People have strange questions.
 
@rubenvb why don't you try the Intel MKL Random Number Generators software.intel.com/en-us/forums/showthread.php?t=83462
 
18
Q: Which kind of pointer do I use when?

sbiOk, so the last time I wrote C++ for a living, std::auto_ptr was all the std lib had available, and boost::shared_ptr was all the rage. I never really looked into the other smart pointer types boost provided. I understand that C++11 now provides some of the types boost came up with, but not all o...

Oh nice, a new FAQ, hadn't noticed before!
 
3:40 PM
7
Q: Is C++ a "waste of time"?

UnknownI ran into this supposed interview of Bjarne Stroustrup, the inventor of C++. http://artlung.com/smorgasborg/Invention_of_Cplusplus.shtml Stroustrup: Well, it's been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it's ...

lol
 
What makes an abstract data type abstract? Is it abstract-data type, or abstract-type?
I used to know all this stuff. ><
 
Xeo
Huh?
struct abstract{ virtual void foo() = 0; };
 
@Xaade Abstraction. Apply directly to the forehead.
 
http://www.desy.de/gna/html/cc/Tutorial/node4.html
None of this tells me why it's called abstract. It just describes it. I'm assuming it's called abstract because the data isn't accessed directly... but that's what all my classes do?
I just don't get what all the fuss is. It looks like what I do everyday. It's not a technique, it's just how I code?!?
 
@Xeo: no that is an abstract class due to pure virtual function. ADT is something else. struct Namestring { std::string value; }; is an ADT, instead of std::string (which would be general data type?)
 
3:50 PM
It's theory mumbo jumbo.
 
I never have public data.
 
Xeo
I only have public variables for traits classes
 
The rationale, as I remember it, is that it is easy to change the implementation of Namestring to something else. (Of course you want to restrict the interface, I was being very quick and drafty there)
 
See, why do they put all these names on shit. All it does is teach people how to put puzzle blocks together. Not how to program something good.
 
sbi
@FredOverflow It grew out of a question I dropped here.
 
3:53 PM
Programming is putting puzzle blocks together.
 
Xeo
1
Q: what's wrong? dangling pointer?

tinybit#include<iostream> using namespace std; int *p = NULL; void fun(void){ int i = 10; p = &i; } int main(void){ fun(); cout<<*p<<endl; //#1 cout<<*p<<endl; //#2 return 0; } I think #1 and #2 will output the same, but why #1 output 10 a...

Not another one....
 
@Xaade It's an abstract datatype :)
An ADT is specified by its behavior (as opposed to its implementation).
> ADTs were invented to tell you how a stack works.
 
@Xeo not much to add there, the data is undefined when you leave the function
 
2
Q: Learning C++ and overcautiousness

nonameHow should I learn C++? I hear that the language gives enough rope to shoot myself in the head, so should I treat every C++ line I write as a potential minefiled?

> I hear that the language gives enough rope to shoot myself in the head
lol
> It also gives you enough bullets to hang yourself.
36
A: What is a lambda expression in C++11?

awoodlandThe problem C++ includes useful generic functions like std::for_each and std::transform, which can be very handy. Unfortunately they can also be quite cumbersome to use, particularly if the functor you would like to apply is unique to the particular function. #include <algorithm> #include...

Is the line f f; legal? If so, it certainly is potentially confusing...
 
I don't think so.
 
4:06 PM
96
Q: Throwing the fattest people off of an overloaded airplane.

IvyMikeLet's say you've got an airplane, and it is low on fuel. Unless the plane drops 3000 pounds of passenger weight, it will not be able to reach the next airport. To save the maximum number of lives, we would like to throw the heaviest people off of the plane first. And oh yeah, there are milli...

lol @ title
 
> And oh yeah, there are millions of people on the airplane, and we would like an optimal algorithm to find the heaviest passengers, without necessarily sorting the entire list.
 
lmao here :)
 
Xeo
That topic was awesome
 
Millions of people? Must be quite an enormous airplane :)
 
it's space ship
 
user142019
4:11 PM
It uses heavy compression.
 
Xeo
21
A: Throwing the fattest people off of an overloaded airplane.

jabolotaiThis won't help for your proxy problem, however: For 1,000,000 passengers to drop 3000 pounds of weight, each passenger must lose (3000/1000000) = 0.003 lbs per person. That could be achieved through jettisoning every ones shirt, or shoes, or probably even fingernail clippings, saving everyone. ...

This is still the best answer there
 
sbi
@Xeo Dupe. Voted to close.
 
> Actually, they don't allow fingernail clippers on board anymore, so that's out.
 
Xeo
@sbi I wonder if the "closed off as duplicate" question should be made a c++-faq
I mean, it definitly qualifies.
 
sbi
@Xeo Maybe.
 
Xeo
4:13 PM
It's not only frequently asked, it's overfrequently asked
 
After a long pause, I just got another blue screen. ati2cqag.dll sounds like a graphics card driver problem.
 
user142019
Crashes suck.
 
Possibly.
If it persists after driver upgrade, it might also be hardware fault.
 
Interesting. It looks like a sound card driver problem?
But is sounds like a graphics card driver problem
 
@WTP Are you referring to the blue screen or the overloaded airplane? :)
 
user142019
4:22 PM
@FredOverflow BSoD
 
@sehe lol
 
"The plane crashed because there were too many fat people on board."
 
Meh, test tomorrow. Fourier transforms and all that not-really-fun stuff.
 
I was never able to keep non-discrete mathematics stuff in my head for very long.
 
4:28 PM
I can't keep it for 5 minutes, and I have to remember it for a whole day.
And then again two weeks from now.
 
@CatPlusPlus Agreed. Wavelet transforms and Lagrange Polynomials are much more fun?
 
@CatPlusPlus I have to imagine the pouting with that
@IntermediateHacker There. I reimplemented your compiler (sic) thingie. In about 20 lines of perl, plus the TOP/BOTTOM templates. See it live: ideone.com/H5z0d
 
sbi
@sehe Ah pouting cat. A sight for sore eyes.
 
4:35 PM
@IntermediateHacker I reproduced the bug too: else if is not handled correctly.
 
Xeo
@FredOverflow Fuck yeah.
 
sbi
@Xeo Hey, keep it down. Remember the Dick Rule™ :)
 
Xeo
@sbi Fuck noez. :(
 
@sehe Lol.
Also, compiler is something that translates one language into another, so no sic necessary, really.
 
@IntermediateHacker: the good news: that found the bug with the unbalanced braces. The better news: I fixed your global namespace references to avoid clashes.
 
4:38 PM
Also, implicit magic variables are stupid and evil.
 
@IntermediateHacker The slightly less good news is that I can begin to enumerate the problems, and be done in 2012, only because I can start so early in the year.
 
@sehe thanks.
 
@CatPlusPlus Especially when they are only handled at the start of a line. Function calls, however, get handled when appearing inside string literals, just to name a nice one
 
What strikes me as odd is "pro_compiler_r11" and "pro_compiler_r10" folders.
In an SVN repo.
 
@CatPlusPlus: subversion style branches, nothing special. The trunk/branches/tags layout is convention only
 
4:41 PM
Branches, hm.
Yeah, I remember that. Poor VCSes with flat history.
 
I'm working on r12 currently.
I'm working on support for functions.
 
See, now that doesn't sound like a branch.
 
@IntermediateHacker: let me guess. You were tinker -ing with LINQ
 
@sehe yeah. lol.
 
Branches are usually made so that work can be done in parallel.
 
4:43 PM
@IntermediateHacker can I give you a hint: please don't stop if it is merely for your own educational purposes. Otherwise: stop it now!!!
 
If you just copy and forget the old version then that's not version control, it's like those "project", "project backup", "project 2011-11-11" folders.
 
@sehe yeah it's for my education. so I won't stop.
 
Boo, nemerle, IronPython, IronRuby have all succeeded in filling the same gap - only for real. Even csharp <<< 'Console.WriteLine("Hello World!");' on any mono installation does the job
 
Something existing is not a reason not to do the same thing for fun.
Or even as a serious effort, if you really feel existing solutions suck.
Though with languages it's really better to sit and think about it first, instead of patching the thing together on the go.
 
@IntermediateHacker That's good :) The C# isn't actually so bad. Though I would venture that the use of line = line.Trim().TrimStart(key.ToCharArray()) is particularly evil and... hacky. Likewise for the key = line.Split('(')[0].Trim(); idiom, so to speak :)
 
4:47 PM
Otherwise you end up with PHP.
Or Perl.
 
So true. I was pondering to write this is C++ and translate to C++ code on the fly. I reckon it wouldn't be too hard, really.
@IntermediateHacker Are you interested in learing how to parse properly, the C# way? I can heartily recommend CoCo/R
I just noticed that they landed my patch to get "Support for #line pragmas in the generated Parser.cs" that I submitted loooong ago
 
5:03 PM
Why do we edit with fixed-width fonts, anyway?
@CatPlusPlus I disagree. In git, at least, I use branches to group anything that takes more than a couple of commits.
 
Group how?
 
A set of commits that work to solve the same problem go in the same branch.
It's just logical.
While branches are, indeed, very useful for parallel development, I don't always use them for that.
I rarely do on my personal projects, in fact.
 
There's a concept of a feature branch, but it's still a form of parallel development. At the end, you always merge the branch back into one of the main trunks.
 
Mmh. I've never programmed anything that's required a stable branch.
Personally, the biggest hurdle for me is what to do with VCS before the project can build properly.
I don't want to commit code that won't compile, but I also don't want to go a while without committing anything.
 
5:18 PM
Nobody expects project to be buildable from revision 0.
VCS is for tracking development. You should commit as often as possible.
If you need buildable snapshots to be visible — there you go, stable branch.
 
Hmm.
 
Stable here doesn't mean "never changes" or "finished".
 
I guess you're right.
 
0
A: Is it possible to use template metaprogramming to do compile time selection of functionality that class will perform?

refpVariadic templates (C++11) enum LoggerType { NONE, PERCENT, DATE, TIME }; template<LoggerType T = NONE, LoggerType ... Next> std::string LogHelper () { return LogHelper<T> () + "; " + LogHelper<Next...> (); } template<> std::string LogHelper<NONE> () {retur...

I feel as if that could've been written in a much cleaner manner, any ideas?
 
Xeo
I don't understand why everyone specializes the logging functionality. See my answer
 
5:30 PM
@Xeo to be honest I find your solution to be somewhat messy
 
Xeo
@refp Why? Because of the parameters?
 
it's overly complicated
 
Xeo
I find template specializations for every optional functionality to be overly complicated.
The syntax could be nicer for passing the member function, sure, but that's more or less C++'s fault
0
Q: Convert non-null-terminated char* to int

cmorseI am working on some code that reads in a data file. The file frequently contains numeric values of various lengths encoded in ASCII that I need to convert to integers. The problem is that they are not null-terminated, which of course causes problems with atoi. The solution I have been using is t...

Ugh
 
1
A: C++ for C# Developers

MuhammadBelieve me pick a good book on C++ (there are much more, just do a search) and start learning...

> Myself, what I like in C/C++ is the low-level staff it provides!
low-level staff? :)
 
5:47 PM
You know, the people that take away the chamber pots and such.
 
Oh, there was some politicking while I was way. Did I get elected emperor and don't know it?
 
Emperor? Do you at least wear clothes?
 
I wear a mind!
Ah, there's a summary on the newbie hints, cool.
 
@Xeo what do you think about the c++03 solution?
 
5:53 PM
@FredOverflow Freudian slip.
 
0
A: Is it possible to use template metaprogramming to do compile time selection of functionality that class will perform?

refpPreface Two solutions will be found in this post, one using C++03 and the other C++11. It's hard (ie. you'll need to write a lot of code) if you'd like a true compile time if that is guaranteed not to have any runtime overhead what so ever (no function jumps, etc etc). It is however possible, ...

 

« first day (444 days earlier)      last day (4489 days later) »