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
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
00:46
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)
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
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
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
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
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
01:22
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
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...
@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
@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.
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.
@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.
@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.
@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.
@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).
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.
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.
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; };
@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.)
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.
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.
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.
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 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)
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.
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?
@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)
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.)
@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
@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
@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.
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. — sehe1 min ago