« first day (422 days earlier)      last day (4752 days later) » 

20:00
What? Questions on vim are off topic?
Humm iterators? I thought more like template < class Telem, class Tcontain >
void qsort(Tcontain<Telem>) { .. }
@Pubby No, they're not off topic.
-1
Q: Vim abbreviation using colon?

PubbyI want to do some abbreviations that contain colons, but it doesn't work in vimrc: ab t:u unsigned I get a syntax error. I tried \: and \\:\ but it didn't work. How can I do this?

@Pubby Flagged.
> We have over 5000 vim questions. They were never off-topic. Plus, the FAQ states that questions about "software tools commonly used by programmers" are on-topic. I believe this question should not have been closed.
>"The people that come up with these kind of things are obviously way above
>average intelligence, what a waste, go find a cure for cancer or something."
20:03
Who said that?
@RMartinhoFernandes Thanks.
And Markdown wins again.
4th time this week!
> "The people that come up with these kind of things are obviously way above average intelligence, what a waste, go find a cure for cancer or something."
quote from someone discussing the Ethical implications of using anti forensic tools
Because Biology is very similar to Computer Science...
humm why do I get a syntax error for

template <class Tcontain>
void qsort(Tcontain<int> a) { ..}
20:07
because .. isn't valid syntax
Because Tcontain is a type, not a template.
template <typename Container> void qsort(Container& a);
it bothers me how class isn't enforced unless it's a template template
What Cat said.
20:10
int is not a class, but can be used for class template parameter
but typename can't be used for template templates :(
sucks
class being accepted instead of typename in that context is just historical artefact.
backwards compatibility has caused 90% of c++ stupidity
It was never 'enforced', whatever that would mean and whatever the use of that would be.
I found out about how the keys in public and private keys work :) But I didn't really understand it
20:12
No one does.
It's something to do with modulo arithmetic and it's properties and stuff and then how large products of primes are hard break into it's factors p * q and blah blah blah
Dammit. If I run my program through glslDevil all I get is an endless sequence of calls to wglGetExtensionsStringEXT. WTF?
If I run my program through glslDevil all I get is a crash.
20:15
my old video card used to compile glsl code it couldn't run
I'm not sure my situation is better than a crash.
@Pubby aehm that's why it is compiled by the driver, right?
sbi
sbi
I guess I pissed off the guy:
@tweetsbi You think in thirty one years of programming I haven't read some books on STL? Code a game.
rofl
then ask him why he did something so colossally stupid as to use a linked list :P
humm I'm not sure weather qsort can be implemented with containers as elegant as with pointers
because I need to break up the sequence into two pices
20:17
@Nils Of course it can. Why can't it?
std::sort
nothing can implement it as good as haskell
sbi
sbi
@Nils A pointer is an iterator.
@DeadMG and with pointers I just do qsort(a + lower + 1, len - lower - 1);
wHAT
20:18
you can do that with random access iterators too
sbi
sbi
@Nils Do the same with std::vector<T>::iterator.
it is about time I care about what iterators exactly are
btw
for a pair of sets, sized M and N, it should be possible to determine that they have no elements in common in O(min(N, M))
right?
uhh so qsort would accept an iterator and a length instead of a pointer and length?
no, iterator begin and iterator end
20:19
No, an iterator range.
i.e., instead of qsort(iterator, length) you'd be looking at qsort(iterator, iterator + length)
sbi
sbi
@Nils Iterators are an abstraction of pointers, sorted into categories regarding how much they are like pointers. Random access iterators are the most alike. (In fact, some early implementations of the std lib implemented std::vector<T>::iterator as T*.)
Getting length might be much more expensive than getting begin/end.
indeed
although random-access containers probably have O(1)
@DeadMG if you see the iteration op "++" of the set as being constant, then I think so, yes
sbi
sbi
20:20
@Nils Why are you so fixated on using std::qsort()? What's wrong with std::sort()? Usually it's faster that the low-level C code.
thx @sbi
@sbi I think he's writing qsort.
@sbi I am just learning
@sbi He's writing qsort, not using the crappy C library function.
sbi
sbi
@CatPlusPlus I thought so, too, at first, but why then is he worried about its signature not fitting his need? / cc @RMartinho
20:22
I have a quick question, why isn't std::sort overloaded for list iterators?
sbi
sbi
@Pubby How would you implement it? (Hint: You cannot get at a container from an iterator.)
it's a flaw in the C++ free function design
there's a special member function on std::list, but you can't use it when calling std::sort, because you need a pointer to the container
@sbi there are sorting algrorithms for that, right?
sbi
sbi
@Pubby std::list<T>::sort().
it makes no sense to say "std::sort is faster than ::qsort" IMO
20:23
of course it does
in general, std::sort is faster than qsort because std::sort can be inlined and qsort can't be
::qsort is ugly.
passing a void(*)(T&, T&) as comparator to std::sort will result in equal speed than for std::qsort
constant folding could get around that
but also, the sort algorithm itself can be inlined, not just the comparator
a possible non-function-pointer function object you pass as comparator can speed functions up by making inlining much easier
Wolframalpha was taking ages to break this number into it's prime factors :(
5759602149240247876857994004081295363338151725852938901132472828171992873665524051005072817707778665601229693
20:25
but that doesn'T mean that std::sort itself would be faster somehow. only if you use it together with a special kind of function object
the algorithm can be inlined
not just the comparator calls
@DeadMG if it can be inlined for std::sort then it can be inlined for qsort
@Pubby: neat, your question got fixed up :) stackoverflow.com/q/8476998/46642
And I gained 300 grams of flag weight.
why?
qsort might be dynamically linked from the CRT
@DeadMG because there is no reason why it couldn't
@DeadMG well, might.
20:26
@RMartinhoFernandes I actually talked to casperOne. He said he forgot what vim was.
it can be provided as an inline function
sure, it might be inlined
but it's not very likely
sbi
sbi
@DeadMG I disagree with this. It's an outcome of the decision to use pairs of iterators (which favors compatibility with C arrays and pointers), rather than single ones. Had we ranges instead of pairs of iterators, containers could pass as ranges, and we'd call std::sort(my_vector) and std::sort(my_list). I'd prefer that, but I wouldn't have known I'd do this 15 years ago when those decisions were made, so I can't complain about them.
@Pubby lol
Ranges FTW.
sbi
sbi
@JohannesSchaublitb I didn't say that. I said it's usually faster. This implied comparability, of course.
20:27
@sbi You'd have an identical problem if you wanted to sort anything except the whole range.
sbi
sbi
@DeadMG A subrange is a range.
yes, but the container cannot pass for a subrange
@DeadMG only for particular implementations
it is not a problem with qsort itself
you're right, forgive me
i bet high quality implementations provide an inline qsort
20:28
Turns out that reviewing quicksort is a pretty good exercise, also with regards to C++ :)
sbi
sbi
@DeadMG std::sort(my_list.take(5))
it's not a problem with the function, only the vast, vast majority of it's implementations
sbi
sbi
@JohannesSchaublitb Name one implementation that inlines std::qsort().
@sbi Random access iteration on a list?
struct the {};
std::vector<the> take(int);
for(the team : take(1)) {}
20:29
@sbi my implementation would provide an inline definition
but i don't know one actually existing
but that doesn't mean that there isn't one :)
Argh, I just spent half an hour bug hunting because I assumed a readBytes method would return 0 if there were no more bytes to read, but instead, it returns -1.
lol
That's a bit silly, ain't it?
BTW what do you guys think about my "initializer lists for converting constructors" proposal?
What does a 0 return mean?
it means "I read no bytes."
sbi
sbi
20:30
@DeadMG Who said anything about random access? This simply returns a single-iterator/range/subrange that will hit its "end" after five increments.
@RMartinhoFernandes My assumption or the API? Well, it's a Java API...
@JohannesSchaublitb Do you have a link to it?
@FredOverflow The API.
sbi
sbi
20:31
@JohannesSchaublitb No, but it means that, usually, std::sort() is faster than std::qsort(). QED.
Another Java failure: I assumed someByte >>> 4 would return a value between 0 and 15. Guess why it does not.
@Nils Doesn't he pay attention to compiler warnings?
they clearly warn you when you compare between signed and unsigned
sbi
sbi
@FredOverflow It's a rotating shift?
@FredOverflow What's >>>? Rotate right?
@RMartinhoFernandes It's unsigned shift right.
20:32
Shift without sign extension?
@sbi that would imply that I know most implementations
@DeadMG IIRC there was the same question on twitter and he replayed that the compiler could not catch it because of something.
in addition
@RMartinhoFernandes No it means you get zeros from the left shifted in instead of the sign bit.
in order to get a signed/unsigned comparison bug, you have to actually use unsigned in the first place
20:33
since I know zero implementations of qsort, me knowing of no inline implementations of qsort means nothing :)
and if you do, then you get what you ask for- more range, with a price
@FredOverflow That's shifting without sign extension.
Tin
Tin
Hey guys, I just posted a question about handling smart pointers in containers. If you could shed some light, it would be great :-) stackoverflow.com/questions/8479938/…
@RMartinhoFernandes No, it isn't. Sign extension has to do with widening conversion. Which is exactly what happens here. The byte (which is signed in Java) is sign-extended to int, and that int is then logically shifted to the right.
sbi
sbi
20:34
@JohannesSchaublitb What is there to know in order to know "most implementations"? I suppose neither VC nor GCC nor clang can inline it. That would cover 90% of C++ compiler users.
WHY ARE JAVA BYTES SIGNED?!?
because there is no unsigned in Java
@Nils Yes there is, char is an unsigned type with values from 0 to 65535.
20:35
ah interesting
@sbi whether there exist an inline definition of qsort is not a property of the compiler, but a property of the standard library
@FredOverflow At least .NET got that right.
i don't mean to talk about the ability of the compiler to inline it
The standard CLS numerical types are all signed, except for byte.
if it cannot inline an inline definition of qsort, then it cannot inline std::sort
sbi
sbi
20:35
@JohannesSchaublitb Are you pulling my leg? 90% of the C++ std users use one of three std lib implementations. What is your point?
Is SHA-512 the best one-way hashing function?
Best for what?
MD5 is faster.
@sbi we will have to see whether those three implementations have an inline qsort
sbi
sbi
@JohannesSchaublitb No, it might be unable to, but it can inline the comparison in std::sort(). And that makes all the difference in the world. (Why am I telling this to you? You must know that yourself.)
Uniquely "identifying" something. Least probability of collisions and stuff.
20:37
VCSes nowadays tend to use SHA1 for that purpose.
@sbi if it cannot inline std::sort then it cannot inline the comparison if the comparator is a function pointer.
so it depends on the use of std::sort
if one uses std::less<> then it could easily inline the comparison
but if not then it becomes harder
They deleted the Lounge<C++> room!
if not impossible
sbi
sbi
@JohannesSchaublitb Of course not. That is why everyone prefers function objects for std::sort().
@JohannesSchaublitb He didn't claim it was always faster.
20:39
hello
@RMartinhoFernandes i don't dispute that it is sometimes faster
virtually always faster
/me tastes the newbie's median
plus
you're ignoring the benefits of having non-specified algorithms
std::sort often uses more than just quicksort in the smart cases
qsort can use more than just quicksort i think
20:43
I doubt qsort is just a quicksort.
if not, then by the AS-IF rule it may still
sbi
sbi
@JohannesSchaublitb Usually.
hm wait, the user could record the sequence of calls to the comparator and compare the pattern and prove that it wasn'T quicksort
@DeadMG do you have some kind of living document with information about your language?
No, he doesn't write anything down. Don't bother trying to convince him.
sbi
sbi
20:45
@Raynos How would someone going by the name @Dead have a living document?
Also, TEXTURES Y U NO LOAD.
@sbi who says the dead can't own living entitites?
yeah, it's called "my head"
that's living
Are you saying my imaginary skeleton friend doesn't own his dog?
20:46
although how you're going to access it, I don't know
sbi
sbi
@Raynos Binky isn't a dog.
grabs lobotomy kit
@DeadMG I can try the repeated annoying questions technique
@sbi It's a horse!
go ahead, ask what you want
sbi
sbi
20:46
@RMartinhoFernandes Tell him, not me!
@DeadMG You might not know this, but with a lobotomy kit, there's no need to ask you.
lol
sbi
sbi
@Raynos Like we tried when we wanted to convince him to use VCS and TDD? Good luck!
@DeadMG doesn't use VCS ?
at least the llvm.org/demo/index.cgi appears not to optimize sorting "{1, 2, 3, 4, 5}" to a noop
i thought it does so
i mean if it inlines it could see that all the comparisons are true and no swap is needed
I do, at some point
but for a start, it's private
20:48
Since when is this the kitchen?
Can I subtract iterators from each other?
and secondly, I never got around to fixing it after changing some machines broke
@Nils If you can do it with pointers, you can do it with random access iteratrs
@Nils If they're random access iterators, yes.
He is embarassed about the code :)
1
Q: C++ how to add extra information to a field

user231536I have a class Student with a single integer variable class Student { int id;... }; Sometimes id refers to Students's id and sometimes it refers to an autogenerated id that is completely unrelated to the student's id (maybe the student had no id at all or did and was ignored). The problem is...

sbi
sbi
@Moshe When did you look last?
Variant to the rescue!
@Pubby there is no paper yet
only a thought
@sbi What, there's a snowman now for pings?
Haha.
the problem is, that list initialization and conversion constructors don't play well together
sbi
sbi
20:50
@Moshe Not for me.
man
(Also, upboat me.)
I love auto&&
my lief, it so ez
@CatPlusPlus Done.
imagine boost::optional< vector<int> >
20:51
Hey, there is a snowman!
to initialize it, you cannot say opt_type o = { 1, 2, 3 }
sbi
sbi
@DeadMG Wait until you have to maintain that implicitly typed mess.
@sbi You have to refresh.
but you need to say opt_type o = {{ 1, 2, 3 }}
I don't want a snowman!
sbi
sbi
20:51
@CatPlusPlus Yeah, I just realized.
because every constructor there is requires one deeperlevel of braces
Xeo
Xeo
Where the hell do you get those snowman from anyways?
you don't have to
implicit typing fixes itself :P
@Xeo Plinks.
Xeo
Xeo
Oooh
20:52
@Pubby things are clear?
1 hour ago, by R. Martinho Fernandes
user image
Now we demand unicorns!
Xeo
Xeo
Those guys sure are bored
@JohannesSchaublitb Yeah
Snowman? Eh, I want a latke!
sbi
sbi
20:53
I find a snowman silly on an international site. It's currently summer in big parts of the world, and there's no winter ever in many others.
@Pubby so i'm seeking for a way to say "this constructor wants an initlist as a one-argument, instead of the initlist elements each to their own ctor parameter"
well, virtually all the site policies are Merkin
there's nothing new about that
@sbi But a latke works because it's not dependent on the weather.
@JohannesSchaublitb Makes sense. Good luck with your proposal
I really need something to make
20:54
@sbi You know what part of the world sets the pace here.
I'm lacking creativity
so you could say opt_type o = { 1, 2, 3 }, and the ctor having vector<int> as parameter type would be marked "whole_list" or something. the { 1, 2, 3 } would be passed as one argument, instead of as three ints to that ctor, and then the { 1, 2, 3 } could successfully construct the vector
@KianMayne Make me a sandwich.
sbi
sbi
@RMartinhoFernandes Indeed. Welcome to the bible belt!
@RMartinhoFernandes Something to program -__-
20:54
same with any other wrapper type that locally represents or can represent the same value as the wrapped type. i.e variant<T1, T2, ...>
@Pubby thanks xD
sbi
sbi
@RMartinhoFernandes That ought to be "sudo make me a sandwich".
@KianMayne Make me a sandwich making robot.
Xeo
Xeo
Great, now I used up all my moderator attention flags
@RMartinhoFernandes It's called a shop
Modern humans owe their existence to the disappearance of Elephants from the Middle East http://www.physorg.com/news/2011-12-elephant-modern-years.html
20:56
@Pubby ideally I think that for non explicit ctors the extra braces should not be required, and only for explicit the extra braces should be required
Extinctions FTW.
I want sandwich, too.
because explicit is exactly what is needed: a way to say "this ctor accepts a value logically of the same kind as this class"
@JohannesSchaublitb Yeah, seems logical
although limitations usually aren't good
man
such a shame that I can't use constexpr associative containers
without going to MPL, anyway
20:58
why are there snowmans ?
Because it's winter, silly.
But it's autumn!
why weren't there hot chicks in the summer
2
Or spring.
Or some indeterminate tropical or polar season.

« first day (422 days earlier)      last day (4752 days later) »