« first day (559 days earlier)      last day (4372 days later) » 

12:00 AM
I'm pretty sure a quicksort is possible in O(1) space, I think I got enough of an idea to start coding. My diagrams look good to me. It does require extra swaps.... I think it's n extra swaps. Probably not overly useful, but I'll probably code it anyway
 
user1174868
12:40 AM
Hey gang, any americans on?
 
Freedom you say?
 
user1174868
no
 
user1174868
There is no freedom in America, just the freedom for the rich to exploit the poor
 
Canadian
 
Being American does have it's downsides when you're traveling internationally.
 
user1174868
12:43 AM
I was just wondering if anyone knew anything about american schools
 
user1174868
I haven't noticed any, and I have been to a lot of countries
 
I remember faking that I was Chinese while I was in the Middle East. I'd be like.
 
@Jordan noticed any what ? American schools ?
 
They'll ask me where I'm from. I'll answer "I'm from Hong Kong" - and with a fake accent.
 
user1174868
Any problems travelling as an american
 
user1174868
12:46 AM
also I have this mentorship thing through some organization, are those worth doing? Do I get anything out of it? It is a year long mentorship thing, I think it is just email/phone contact
 
There are definitely places where I wouldn't go as an American. Even though I can fake as a Hong Kong citizen, I've never actually lived there. So I can't get one. (though my parents do)
 
@Jordan sounds like you should do some research
 
user1174868
I am trying to decide what school to go to for csci in the states
 
user1174868
basically I need to find a school with really, really low standards but still a decent education
 
user1174868
My gpa is too bad to get into any good school, but there has to be a desperate school out there somewhere that wants to exploit my bank account and desire to learn
 
user1174868
12:53 AM
 
user1174868
those are two party schools that I can probably get into
 
perhaps you should talk to a guidance counselor
 
user1174868
I have, I am at an inner city community college, they don't know of computer science
 
@Jordan More or less American, anyway.
 
user1174868
life sucks
 
user1174868
12:58 AM
:P
 
@Jordan Generally believed to beat the alternative...
 
user1174868
too much philosophy for a c++ room
 
@Jordan do you write a lot of code now ?
 
user1174868
no
 
user1174868
I am going to get a B in my intro to programming class
 
1:00 AM
what has you interested in cs ?
 
user1174868
first programming I have done
 
user1174868
I enjoy programming
 
what lang ?
 
user1174868
C++
 
you have C++ in high school ?
 
user1174868
1:01 AM
lol
 
user1174868
I am 26
 
user1174868
I have over 100 credits
 
beg pardon
 
user1174868
I am just really stupid
 
@ScottW pascal was my first language too... but not in high school.... my high school only had typing class
 
user1174868
1:02 AM
That is my concern I have over 100 credits but a 2.7 gpa
 
user1174868
I can't really go anywhere in school
 
@Jordan have you applied anywhere ?
 
user1174868
not yet, my GPA is too low
 
user1174868
Another question I have should I take a Objected Oriented Programming class in C++ or should I take Structure of Programming 1 and 2 with scheme and python? Neither transfer to any schools directly. The C++ teacher is bad but the other one is really good but really hard which will further ruin my gpa probably
 
tough spot to be in... do you have courses that you struggle with more than others ?
 
user1174868
1:06 AM
math and science I gets Cs at best in
 
math is typically a pretty large part of a CS degree
 
user1174868
Yeah I know, I like math and I want to be good at it, I just am not
 
user1174868
I am too stupid to be good at math but not smart enough to not pursue it :P
 
you've called yourself stupid a couple of times already... you might want to start by changing your view of yourself.... just because something is difficult doesn't mean you are stupid.... I can't draw anything... I don't consider myself stupid, I was terrible an english and french... don't think of myself as stupid...
 
user1174868
yeah I am just pretty upset about finding out that 3 of my schools choices are not possible because I consistently fail to get good grades
 
1:11 AM
what gpa do you need to be able to apply
 
user1174868
It is just depressing to find out that I get average grades in school, I am an average person I guess, but that isn't nearly good enough for colleges, they only accept the best
 
user1174868
3.2
 
user1174868
I just feel like there isn't anything I am good at, really it sucks
 
are you good at programming ?
you like it...
 
user1174868
I am pretty bad at it but I like it
 
user1174868
1:13 AM
I score below average in my class on the tests
 
most wise people will tell you, that you are better off perusing something that you really enjoy... because chances are you will become good at it
its the passion that ends up being the engine for your success
plus it generally doesn't feel like work...
 
user1174868
Yeah I have heard that, I just have trouble finding something I am passionate about
 
always the hardest part
sometimes you just stumble onto something
 
user1174868
I have had a "career" and 3 other majors I didnt like
 
you can cross those of the list... the good and bad... there are thousands more out there
 
user1174868
1:17 AM
it is just too bad it costs so much money and time to figure it out :P, if I pursue csci it will be 7 years of school
 
gerd derm rsa
 
i don't know about the 7 years thing... sounds like you have some other programming courses you can try locally... might be a good idea... to see if you still like it after being challenged
 
user1174868
yeah, I am trying to figure out what to take next
 
user1174868
other 2 other classes are offered
 
user1174868
both are intended for transfer to a specific school
 
user1174868
1:22 AM
One is C++ based but with a really bad teacher, the other is a really hard "weed out" class that uses scheme but with a really good (but hard) teacher
 
there will be more "hard" courses after this one... if you want to get to the end of the road... you gotta be willing to walk through the hard sections
 
user1174868
yeah I know, I am just not a good student and my biggest problem is grades right now
 
user1174868
I mean I am going to get a B at best in the intro class
 
if you want it bad enough you'll make it happen... I do feel for you Jordan... but I know that you'll make it if you are hungry enough
grades aren't everything.... sometimes people are just lousy at tests....
are you getting the concepts ?
 
user1174868
Yes, I just forgot simple stuff like syntax or something slips my mind on the test
 
1:27 AM
yeah... I always had a problem with losing marks for syntax.... very few people are able to write a program of any size and have it compile the first try...
well good luck Jordan... i wish you well
 
user1174868
thanks :P
 
knock knock
Anyone here?
I'm trying to debug a segfault in a simple HW problem.
 
user1174868
What is a good IDE for C++ besides visual c++ (broken on my PC)
 
user1174868
vim?
 
1:44 AM
@Jordan At the risk of sounding like an MS fanboi, I'd say there's currently no other IDE worth the drive space it occupies. To be honest, I'm not all that excited about VS any more either, but the others are even (quite a bit) worse. (I should add that I'm only talking about IDEs, which doesn't include editors like emacs, vi/vim, Notepad++, etc.
 
user1174868
Well I can't get mine to work, it won't load projects so I have to rebuild them every time
 
Ugh, pastie is down.
 
@Jordan Hmm...odd. My big problem is with getting their stupid command-line tools to work right. This is one place Linux is much better -- it knows that depends on what, and will let you see it too. In Windows, installing VS puts a list of a couple dozen items in your "uninstall" list, with little clue of which you really need and which you don't.
 
Alternates?
 
@Moshe Or wait, you mean alterntives for pastie, not VS. Sorry.
 
user1174868
1:51 AM
how do I run a program in command?
 
@Moshe Okay -- what's it supposed to provide that a Boost bimap wouldn't do?
 
@JerryCoffin HW
 
@Jordan Qt creator is decent, and free.
 
user1174868
I went back to trying to fix visual
 
user1174868
2:04 AM
I have spent weeks trying to fix it lol
 
2:19 AM
@JerryCoffin I'm doing this for HW.
So I've got this class called Dict, and a class called DictEntry.
And I'm supposed to make a test driver for them and for some reason, after munging around with the constructors, it segfaults. A classmate says hers memfaults. It's the same code though, on diff machines.
 
I don't see anything obviously wrong with the header. Probably need to look at the implementation to find anything.
 
HI lapsaps
Hi all lapsaps
 
@JerryCoffin K, one sec.
 
2:35 AM
oi Mosha
Hi lapsap
 
oi Moshe


Hi lapsap
 
@Moshe Your copy constructor looks a bit wrong. You're using the size member from the target, and copying that many items from the source. The source may have a different number of entries.
Not sure what this: Dict::Dict():capacity(MAX_CAPACITY), entries(new DictEntry[MAX_CAPACITY]),size(0){}; is supposed to be -- it doesn't even look like it should compile.
 
2:53 AM
@JerryCoffin so we want to use getSize from the source then?
(where size says how many items there were in the source at the time of copy.)
 
@Moshe Sounds about right. Your code in your assignment operator looks correct. I'd probably move that into a private function and have both the assignment operator and the copy constructor use that.
Doing some more looking, your operator<< for Dictionary has UB -- it says it'll return an ostream &, but doesn't return anything.
 
@JerryCoffin UB?
 
Undefined Behavior. Anything can happen.
 
Ah, thanks.
 
Sure. Gotta go for a while.
Oh, before I go though, you also have a couple of extra semicolons. Generally harmless, but probably want to get rid of them anyway.
 
3:06 AM
@JerryCoffin Thanks. s/;;/;
;-)
 
3:26 AM
We had a C++ training at work this week. At one point we were instructed to create a resizable Array class (aka vector).
We were supposed to allocate using new T[n].
However, I wanted to avoid imposing the requirement of T having a default constructor.
So I used malloc and placement new.
Is malloc the right choice in this case? Or is does the C++ standard library provide an alternative function that can be used instead?
 
@StackedCrooked Yes -- operator new is the "approved" way to get raw memory.
 
I'm not sure what you mean. Are you saying that I should have preferred new T[n] over malloc?
 
@StackedCrooked no -- that's a new expression. You should have used T *data = operator new(size); to allocate raw memory, then used your placement new to build an object there.
That lets you (for example) overload operator new for a specific class, and it will honor the class' definition of operator new.
 
I see. Heh, it was mentioned in the class that operator new only does allocation, not construction.
2
Hey, I learned something :)
However, I don't think I need to overload operator new in order to create a vector-like class.
 
3:46 AM
@StackedCrooked no, you don't. It's mostly for optimization, like when/if you expect to have a lot of small objects allocated, and the overhead of the normal operator new is higher than you'd like (e.g., smallest allocation is usually something like 16 bytes).
 
Hi all
I am looking for someone to explain how enable_if works under the cover since operators are overloaded and only vary on return type. Obviously this has something to do with the way templated functions are treated by the compiler.
 
@BlairDavidson Do you understand SFINAE?
 
Yes
even with the classical negate() example the overloaded methods take different paramers
the return type of the method Does not affect overloading so I am wondering why it works
I understand that it does work
 
5:03 AM
It's magic.
@BlairDavidson Are you implementing operator overloading with enable_if?
 
I guess I don't really get your question then.
 
if I have 2 function enable_f<....>::type a(x t) and enable_if<!....>::type a(x t)
 
enable_if<!...> ? The '!' doesn't look like it's in the right place.
 
you get the idea right?
 
5:09 AM
So you understand SFINAE and are now wondering why enable_if works, correct?
 
correct
 
I assume you have overloads that each take a different enable_if argument. Since the enable_if is passed as a function argument the overloads do vary on argument types. You said they only vary on return type. I must be missing something.
 
template <class T>
typename enable_if_c<boost::is_arithmetic<T>::value, T>::type
foo(T t) { return t; }


template <class T>
typename disable_if_c<boost::is_arithmetic<T>::value, T>::type
bar(T t) { return t; }
 
Ok. So enable_if is something like this: template <bool, typename = void> struct enable_if; template <typename T> struct enable_if<true, T> { typedef T type; };
That make sense?
 
in my example bar(T t) is overloaded twice with the same parameters
 
5:11 AM
Can enable_if be used on the return type?
 
That would be new to me.
 
that is off the boost web site
 
Not saying it can't be.
 
that is why i am stuggling to understand how it work :)
i.e. only the return types are varied
 
5:13 AM
You named the functions foo and bar, so there isn't much overloading going on.
 
When one enable_if fails, the entire function is ignored.
 
@GManNickG That brings clarity.
 
but the language does not allow overloaded methods to vary by return type
my conudram
 
@BlairDavidson I guess that if a function is removed from the overload resolution set then you don't have the problem. (Because only one function remains.)
 
5:14 AM
hahah
it can only be remove at the point of instantiation though
 
But I'm just speculating now. I don't know anything.
 
thus it violates the overloading rules
 
@BlairDavidson @GManNickG might be able to comment on that. I, unfortunately, can't.
 
no one has been able to adequately answer this yet
ok
GManNickG what are your thoughts
 
@BlairDavidson If SO can't answer your question then you can always try comp.lang.c++.moderated.
Or ask Johannes if he's around.
@BlairDavidson You know SFINAE is a bit a hack to begin with.
It's one of those "accidental" features.
 
5:21 AM
true
 
What's the confusion? While the compiler is generating the overload set, it tests to see if it would even be possible. If not, it ignores it, if so, it goes in the set.
 
Well, my Pascal teacher told me that functions can only be overloaded by argument types and not by return type.
Ok, you can ignore me.
 
@StackedCrooked That's correct.
In C++, anyway.
 
Just FYI, I'm a little sleep deprived so I tend to ramble.
@GManNickG So at first sight that code looks wrong.
 
@StackedCrooked Sure, but when you're dealing with templates you simply have to keep SFINAE in mind.
 
5:28 AM
If I think about it: template instantiation must occur before overload resolution.
@ScottW That's the part that you understand? :D
@ScottW Honestly I haven't noticed.
Perhaps, sleep deprived people appear normal to one another.
I had a C++ training this week. It was a little frustrating though. It was a C++03 course, which I understand since C++11 isn't an option yet in most companies. Then the instructor explained that we shouldn't use auto_ptr because it has problematic copy semantics. I responded by saying that auto_ptr is useful when ownership transfer is in order. For example the return value of a factory function can be a auto_ptr<T>. He replied that it's safer to use a boost::shared_ptr in that situation.
Aarg.
That's so wrong.
Ah well.
Training as in brainwashing? :p
On a side note. The Wikipedia SFINAE article has a sample where the overload should be ambiguous, but for some reason isn't.
    template <typename C>
    static yes& test(typename C::foobar*);

    template <typename>
    static no& test(...);
 
Heh, I wrote that.
5
 
@GManNickG Cool :D
@GManNickG I experimented and changed the second overload to static no& test(int), which failed (naturally). But why doesn't the (...) version fail?
 
Ellipses have the lowest overload rank in the language, so the compiler will literally try everything else before it settles on it.
 
Ok, but that doesn't make it unambiguous.
 
Ambiguity means that two things are equal ranks (neither is preferable). Anything is preferable to ellipses, however. You can't be ambiguous with ellipses except with more ellipses.
 
5:43 AM
I see.
Now it makes sense. I learned a new second new thing today :D
It's kind of amazing how boost libraries managed to do things with C++ that would never be considered possible by most programmers. This makes me curious as to which crazy stuff will be invented using the new C++ standard.
BOOST_FOREACH isn't really as impressive anymore when you have C++11.
@ScottW I like the Apple keyboards.
On a PC I would probably look at what Logitech has to offer.
@ScottW I currenty have the wired US English with keypad.
English International is fine too, perhaps even better, but it has a different ~ placement, which is confusing for me.
The US English layout is most standard I think. (At least in America.)
 
@StackedCrooked BOOST_FOREACH is as impressive as how people pulled off move semantics without rvalue references.
Maybe even more impressive.
 
Did people pull off move semantics in C++03?
 
@StackedCrooked Yes, let me find the link.
 
5:58 AM
I want to see that :)
 
> The idiom uses a combination of two subtle (but standard) properties of C++. a) A sequence of conversions via the detail::proxy<T> object is identified automatically by the compiler. b) The conversion function operator detail::proxy<T>() is non-const. This member conversion operator is used to modify the temporary object! (an important exception)
@StackedCrooked impressed yet? ;)
 
Not yet impressed. I'm double checking the details :)
Ooh, that's cool. The T(T&) overload can't be called because a temporary can't be bound to a non-const reference. But since a temporary isn't const itself the operator proxy<T>() can be called.
Which circumvents the restriction.
 
I wonder how people come up with this stuff. They probably shower a lot.
6
 
Or maybe they don't shower for a month and then get inspired when they finally do shower.
 
Anyone know how to take a char value, and print it as two hex characters? (no leading FFFFF and so on). I tried sprintf(%2.2x,ch1) but that did nothing (at least that is what it seemed like). How can I do this very simple thing?
 
6:11 AM
std::cout << std::hex << std::setw(2) << std::setfill('0') << c;
I believe it's like that.
 
printf("%x%x", (value >> 4) & 15, value & 15);
If it's actually an unsigned char, you don't need the first &15.
 
@StackedCrooked, what include do I need for setfill and setw?
 
#include <iomanip>
@FredOverflow Apparently it's invented by Bill Gibbons and Greg Colvin.
 
@StackedCrooked I smell genius!
 
:D
Now I smell it too.
 
6:18 AM
@StackedCrooked, I get "funny" characters when I use that
And the value printed is always zero
 
I guess something is wrong then.
 
Wrong with the input, or with the code?
 
I'm not sure.
 
I would assume that it is not possible for the input to be "wrong" as it should be able to deal with all possible valid values of a char
 
@soandos Did you try my solution?
 
6:24 AM
YOOOOOOOOOO
got the RSA working
 
@FredOverflow, I want to stick this into a file, so not really sure how to apply your idea
 
@Walkerneo Congrats! (in c++?)
 
@ScottW Plink
 
@sehe Python :P
m2crypto
 
6:28 AM
@ScottW, I am still getting ffffff90 as one of the outputs
(when I add the cast)
 
@soandos How about this?
char hex_lut[] = "0123456789abcdef";
unsigned char x = 42;
char a[3];
a[0] = hex_lut[x >> 4];   // needs to be (x >> 4) & 15 for non-unsigned char
a[1] = hex_lut[x & 15];
a[2] = 0;
std::cout << a << '\n';
 
@ScottW, sorry
@FredOverflow, hex_lut is what exactly?
 
@soandos Whoops, sorry, added :) You probably want to put the globally somewhere so it doesn't get reinitialized every time you enter the function.
 
And I am only dealing with signed chars
 
6:31 AM
@ScottW not all wars are decided by numbers. Cf. churchill, Hannibal, Joshua, or even the Gulf War (though, there you could say it was won by numbers: the number of dollars)
 
@soandos Well, respect the comment, then.
 
@sehe Number of winners.
 
a[0] = hex_lut[(x >> 4) & 15];
 
@StackedCrooked I totally read that as 'number of whiners'
 
Very strange, going to have to see what else is going wrong
 
6:32 AM
@sehe Well, I appears that you read it wrong then.
:D
 
thanks for the help @StackedCrooked, @FredOverflow
 
@StackedCrooked Did you know you can replace std::cout << std::endl; with std::endl(std::cout);? :)
 
@StackedCrooked Maybe chars are wider than we expect on his platform?
 
I did not know that.
 
6:33 AM
Well, now you know!
 
@FredOverflow And with ADL it can be shortened endl(std::cout)?
 
I wouldn't know, not an expert on ADL here.
 
Should test. Don't know if endl is a function.
 
ADL is only for functions, not function objects, right?
 
Yes.
 
6:35 AM
std::endl is an object with operator()(some_stream_parameter) overloaded.
 
std::endl is a template function.
 
@FredOverflow ideone.com/YlSSt :D
 
Really? I thought if was a function object. Strange.
 
Yup yup.
 
I don't see how std::cout << std::endl; works then.
 
6:36 AM
Well, I guess there's not a day where you don't learn something new, erm, I mean make_shared, in C++ :)
 
@StackedCrooked operator << takes function objects ? It seems contrived, but it is really not that complicated.
 
Oh, std::cout has an overload of operator << which takes a functor? Dammit @sehe!
@sehe I had just realized it myself :D
 
Why functor? I thought std::endl wasn't a functor after all?
 
@StackedCrooked I think that's what's called called a manipulator
 
It sure manipulated us into thinking the wrong thing!
 
6:37 AM
@FredOverflow Er, a functionable?
 
What is a functionable? A questionable function? :)
 
I don't get it. Some people post many questions and fail to notice how SO works (e.g. 7 questions in 4 months:)
Any time. Don't forget to accept the answer if it solved your problem (click link for an explanation of how that works on stackoverflow.com) — sehe 17 mins ago
 
It has operator<<(self_type& func(self_type&)); defined. When you say std::cout << std::endl;, std::endl's template arguments are deduced based on the destination overload (the char type and whatnot). It's a common mistake to implement the function portion of a custom stream with a templated operator<<, because then endl and kin cannot deduce their template arguments.
 
@ScottW go into a shop, try them out (watch for response, 'tipping point' (slowly exert slightest bit of pressure; there should be 1 definite moment at which the key 'springs'. Preferrably, it should naturally return to the starting position immediately), sound and - perhaps - layout.)
 
@GManNickG What do you mean with "the function portion of a custom stream"?
 
6:43 AM
@StackedCrooked Let's say you want some object to act like an output stream, you might start doing this: struct mystream { mystream& operator<<(int); mystream& operator<<(float); /* etc */};
And then you think "ah, I need it to accept manipulators. I'll allow all functions by doing this: template <typename Func> mystream& operator<<(Func func) { return func(*this); }".
 
@ScottW I did the same last year, and finally got a nice keyboard - which was actually one of the less expensive ones. (Don't recall) It is a Trust 16121-02
 
@GManNickG Ok, like that.
 
But that would be an error, because mystream ms; ms << std::endl; would fail, because std::endl can't deduce its template arguments.
It has to be more concrete: mystream& operator<<(mystream& func(mystream&)); now it works, because std::endl knows what to be.
 
@ScottW It's this one (it's nice and quiet but responsive with feedback and is apparently available in BE version too - dunno if that changes anything)
@GManNickG 'knows what to be' - strikes me as on level of code personification more than usual
 
@sehe Now you've gone and hurt its feelings.
 
6:53 AM
To be or not to be, that is, if one knows what to be!
 
To be or what to be, that is the question
 
To be in the overload resolution set or to not be in the overload resolution set. That is the SFINAE question.
 
My top recommendation is to try them hands-on, though.
It is also a matter of taste. And I'm a keyboardist (I'm a pianist too)
 
7:36 AM
Good morning
 
7:51 AM
Languages in India : English, Hindi, Urdu, Punjabi, Maliyalam, Tamil, Telugu, Bengali, Saraiki, Gujarati, Rajastani, Sanskrit, Sindhi, Pushto, Marathi, Kashmiri, Dardic, Assamese, Dogri, Bodo, Kannada, Konkani, Maithili, Manipuri, Nepali, Santhali, Oriya etc.
Weird how a country can be so incredibly, unbelievably diverse
and these are just the official languages. I haven't even mentioned the dialects.
 
India's economic growth is sometimes unnoticed because it is overshadowed by China. But it's really huge.
 
8:08 AM
@StackedCrooked Boy. America must have too much government. I can't possibly keep up with all of that:
> “[It] is threatening the rights of people in America, and effectively rights everywhere, because what happens in America tends to affect people all over the world. Even though the Sopa and Pipa acts were stopped by huge public outcry, it’s staggering how quickly the US government has come back with a new, different, threat to the rights of its citizens.” -- Tim Berners-Lee
Exactly my sentiment. Too much government risks the opposition just getting outrun/defatigued.
 
Morning all
it's a bit odd to be back in office now
 
The public would loose interest in constantly opposing petty laws and the government would use the moment of weakness to pass a 1984 law quick
@thecoshman how so? Oh, you're a trained monkey now
 
@sehe huh?
@RMartinhoFernandes mostly either food from other countries or bits of animals that is not muscle
 
8:46 AM
I can't believe this question was migrated to Code Review. They turned it in a micro-optimization fest. How useful (not):
@Roshnal can you provide any feedback on this? In all fairness I think this was unjustly moved to codereview, and, though interesting, all micro-optimization beyond final.reserve(in.size()) smells like premature optimization. — sehe 1 min ago
 
@sehe but what use is function with out obscure micro-optimization assembly? and manual loop unrolling?
 
@thecoshman 'huh?' :)
 
yay! I have thought up a name for my menu project thing - but I will be coy about it for a while yet :P
@sehe od damn, but 'what you use' I meant 'what you need', trying to be funny
 
> [...] trying to be funny
 
@sehe :(
 
8:59 AM
^ that appears to be a frequent communication disruptor with us
 

« first day (559 days earlier)      last day (4372 days later) »