« first day (655 days earlier)      last day (4296 days later) » 

Xeo
2:02 PM
53
Q: Never seen before C++ for-loop

ThomasI was converting a C++ algorithmn to C#. I came across this FOR-loop: for (u = b.size(), v = b.back(); u--; v = p[v]) b[u] = v; It gives no error in C++, but it does in C# (cannot convert int to bool). I really can't figure out this for-loop, where is the condition? Can someone please explai...

Seriously, the attention this question gets just plain baffles me.
 
my FB is offline
 
@Xeo 15 comments on the question alone.
 
that is retarded
SO is going full retard
 
sad but true
 
@TonyTheLion Are you becoming like the cat?
 
2:07 PM
I am a cat
remember?
 
@R.MartinhoFernandes No, the cat just thinks everything's terrible
 
I won't upvote because of "... or while(u-- >0) just in case u starts off negative." While this might work, it's motivated by wrong assumptions. If u starts off negative, u-- will never be zero or positive. Signed integer overflow has undefined behaviour in C++. — R. Martinho Fernandes 32 secs ago
 
and no, I'm not becoming like the cat, I'm not saying that all things are terrible. Because, that's a lie
 
I heard that the cake is a lie.
 
GCC MULTILIB Y U SO ELUSIVE?
 
2:13 PM
user image
3
lol
 
Yeah, but how many spaces do you use to indent?
 
@KeithLayne that's the project's codestyle.
 
What ruben said. Four.
 
I switched to two recently. It was a pain.
but I like it.
I removed the "chars per line limit" too.
 
2:15 PM
It's nothing's default, so it's always the first thing to do.
 
Notepad2 has 2 by default.
 
I try to keep my lines a reasonable length. I think 100 i s good. 80 is too small.
 
I sometimes get around 150 when outputting debug crap.
 
I just hate crap getting indented to death at two levels deep.
 
it fits on my screen so meh.
 
2:17 PM
It also helps me go side by side. I like too see everything at once.
 
I just never decided where to continue my broken up line :P
 
I just write short readable lines all the time, so I don't have problems with chars per line limits.
I'm not a good liar.
 
lol
 
@KeithLayne I heard the cake was the truth.
 
for() for() for() if() return a ? b : c;
 
2:19 PM
In fact, cakes are fucking tasty.
The spacecake is an illusion.
 
@R.MartinhoFernandes just for you, my goal is never again to use old-style for loops.
 
boost::iterator_range is handy. And irange.
one of the problems is that I almost always use for instead of while.
 
I find while loops kinda rare.
 
@R.MartinhoFernandes while(stream>>stringthing)
 
2:22 PM
you get free local definition space and increment/whatever, and save lines.
 
@rubenvb But input is not as common as iterating through containers.
 
@R.MartinhoFernandes agreed. You just make "kinda rare" sound like "I never use them".
 
boost phoenix is annoying me though with spirit.
 
Also, for(string s : strings_from(stream)) :P
Proper ranges => do everything with range-based for.
 
istream_iterator?
 
Xeo
2:24 PM
@KeithLayne Boost ranges are fucking unwieldy with their names, though :(
 
@rubenvb Yeah, I should have added "when compared with for loops".
 
Xeo
boost::make_iterator_range, urgh..
 
@KeithLayne that's a pest.
 
@Xeo Boost ranges are fucking unwieldy with their fixation on iterators.
 
@Xeo I'm trying to make the robot proud here.
 
2:25 PM
@R.MartinhoFernandes I've heard a billion arguments, what's the robot's argument against tabs?
 
Xeo
@R.MartinhoFernandes It's not like they really expose that
 
That makes implementation painful as heck.
@Xeo Ever tried implementing one?
 
Xeo
Hm?
Only adaptors
 
Without the ability to easily implement ranges, my dream of range-based for everywhere will never come true.
Someone should make a proposal for C#-like yield.
 
Xeo
@R.MartinhoFernandes I think there already is one
 
2:26 PM
@Xeo Those work one element at a time, right?
@Xeo The next mailing?
 
Xeo
@R.MartinhoFernandes Not really, you just get the range handed :P
 
@Xeo Erm, then that's no help.
 
Xeo
@R.MartinhoFernandes I remember somebody talking about it, maybe Herb?
But really, I don't actually see your problem with implementing from iterators
 
Xeo
Just gimme an example
 
2:28 PM
@Xeo Anything non-trivial (i.e. that can't be written with a simple sequence of | existing_adaptor1 | existing_adaptor2) is a mess.
And the set of existing adaptors is really limited.
5
Q: How can I write an iterator wrapper that combines groups of sequential values from the underlying iterator?

R. Martinho FernandesConsider the following sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 I have input iterators for that sequence. I want to wrap those iterators on iterators that produce the following sequence instead: (1,2), (3,4), (5,6), (7,8), (9,10) If it's not clear, this sequence is a sequence of consecutive ...

 
ah, adjacent_adjacent_group()
 
@R.MartinhoFernandes I've been trying to use that, just for kicks, in MSVC10, and it blows in my face. Is that to be expected, considering how poor C++11 support is on that piece of shit?
 
@R.MartinhoFernandes yo dog, I heard you like iterators. So I thought we could put iterators on your iterators so you can iterate an iterator whilst iterating an iterator
 
Xeo
@EtiennedeMartel It shouldn't
VS10 handles <memory> pretty fine
 
@EtiennedeMartel I may have borked something since I'm not that familiar with the Windows API. But I don't see why it could fail if I got the signature of CloseHandle right.
(And HANDLE is void*, right?)
 
2:33 PM
> error C2664: 'std::unique_ptr<_Ty,_Dx>::unique_ptr(void *,void (__cdecl *const &)(HANDLE))' : cannot convert parameter 2 from 'BOOL (__stdcall *)(HANDLE)' to 'void (__cdecl *const &)(HANDLE)'
Seems like CloseHandle returns a BOOL.
 
@R.MartinhoFernandes I’d argue that if this is hard, then iterator_facade is broken
 
Anyone knows how to specifiy a call convention in a function pointer?
 
Xeo
@EtiennedeMartel The bigger problem is the __stdcall
Just like the error shows
 
@KonradRudolph iterator_facade is only meant to save you from implementing all the operators.
Just like Boost.Operators.
 
Xeo
typedef X (__conv* blah_ptr)();
 
2:34 PM
@R.MartinhoFernandes still.
 
Instead of implementing both operator++ and operator++(int), I only implement increment.
That's it.
 
Xeo
Also, typedefs
 
I’m not able to follow the problem at the moment (brainfart) but this should be an easy problem
 
use Lisp.
 
I'll leave that here: std::unique_ptr<void, BOOL (__stdcall *)(HANDLE)>.
 
Xeo
2:35 PM
@KonradRudolph Problem: He needs to know if the underlying iterator is an end iterator, and seemingly without saving an end iterator :P
 
Seems to work.
 
@KonradRudolph Yes, that's my gripe. But it isn't easy, because iterators suck.
They lack the ability to know if they're usable or not.
 
Xeo
Just take a friggin end iterator
I really don't see a problem
 
@Xeo Yes, and then I'll have 16-iterator-sized iterators in no time.
 
Xeo
I think I see your problem now
 
2:38 PM
@Xeo Well, the same is true for normal iterators – why is this more difficult here?
 
@Xeo It's not about not working. It's about being a mess.
 
I don’t understand why the first increment is happening in the constructor, anyway
 
Xeo
I'd say make it a pairing_range and save an underlying iterator_range
 
(well, no, I do)
 
Xeo
@KonradRudolph To have a value to return on dereference without increment
 
2:39 PM
oh... I just realised... I have some sort of income... that I could put towards buying a ridiculous capacitor bank...
 
@Xeo Ok, yes … so cache them internally and remember the previous iterator position
 
Xeo
@KonradRudolph No need to remember the previous position
 
@KonradRudolph Won't work for input iterators.
 
Xeo
istream_iterators are just the same, the internal iterator is one step ahead
 
If I can do with forward iterators, then it's much easier.
 
Xeo
2:40 PM
Oh, wait
I think I see problem B now
 
Ah, now I see the problem
lol @Xeo
 
@Xeo Yes, they are. I based my implementation off of the standard's definitions.
 
Xeo
I see how equality comparision in pairing_iterators could be a problem
Since the internal iterator is one step ahead, you could prematurely compare equal to the end iterator
 
Feel free to post answers if you find a nice solution. I have given much thought to this matter, and couldn't find a solution without ditching the existing iterator designs.
And I'll be implementing some similar iterators sometime this week, so I'd really appreciate it :)
 
Xeo
hmm
 
2:46 PM
oh man, I can't wait to get home an get on the revised reddit servers :D 1.3 baby!
 
fucking wimp SO chat flags
 
@rubenvb I bet you're glad you're past 10k now.
 
"oh no, he said idiot". "Oh no, he said crapy" [sic]
@R.MartinhoFernandes well, I can validate them too. Very rarely. Or if I'm in a bad mood :P
 
That "for loop" question is driving me nuts. What the hell is v = p[v] ?
 
An assignment.
 
Xeo
2:49 PM
Hm, the equality problem would be easy if you only needed one increment per... increment :s
 
I fail to see how it makes any sense. Does p contains indexes to its elements ?
 
Xeo
btw @R.MartinhoFernandes, what with ranges that have an unequal number of elements?
 
hello everyone :)
 
@Xeo You mean an odd number?
 
Xeo
err, yes
 
2:50 PM
obviously :)
 
You can UB that for that question.
 
WTF? The UB police are coming for you...
 
Btw, in the iterators I'll be implementing next I don't know how many increments I'll need until I read the first value each time.
 
does excel REALLY only support ONE undo by deafult?
 
Xeo
2:51 PM
@R.MartinhoFernandes Like filter_iterator?
 
@Xeo No. Taking the input from that same question, like (1), (2,3), (4,5,6,7), etc. The first element of each "tuple" lets me know the size of the tuple.
 
Xeo
oh god
 
It's a utf8_decoding_iterator or utf16_decoding_iterator, if you're curious.
This would be really, really easy in C#.
 
Xeo
So you're returning a vector then?
 
2:52 PM
No, a codepoint because I consolidate the 1-4 bytes, but that doesn't change the problem.
 
@R.MartinhoFernandes ha, I already knew that :)
 
Xeo
@R.MartinhoFernandes yield, eh
 
@TonyTheLion does it load at some stage?
 
you should move your mouse over the screen
 
still loading... I think :S
 
2:55 PM
@TonyTheLion is that webGl stuff?
 
I think it is, but it's cool nevertheless
 
Okay, so the loop is transforming like [4, 5, 0, 1, 3, 2] to [2, 0, 4, 3, 1, 5] ?
 
oh god, I hate shitty forms on web pages where they don't use the label feature
 
I honestly do not understand GCC's multi-arch support.
 
is the idea that big hit boxes are easier to use really that hard to understand?
 
2:58 PM
the whole lib32/lib64 mess is just that: a mess. And very nonsensical for a cross-compiler.
 
@rubenvb it's easier to cross-compile for something completely different sometimes
 
@KeithLayne lol, wut?
 
i.e. completely different toolchain
 
@rubenvb multiarch on newer Debian is nice though
 
Well, it's nice if it works, it sucks when you have to build it.
Why didn't they just make every arch a subdirectory on its own. Currently, for mingw, you have (for a 32-bit default) <root>/i686-w64-mingw32/lib[|64], and one i686-w64-mingw32/include (which makes installing eg GMP there impossible, because it uses a header dependent on architecture).
They should have moved the specific arch's or platform's files to its own triplet. And let -m64 and -m32 figure out where to look.
But I think I got it working now.
 
3:03 PM
@rubenvb they do have a directory for each triplet now
 
@Flexo No they don't. ("they" as in GCC defaults).
For example: Arch multilib native toolchain: has subdir x86_64-linux-gnu with lib and lib32. It should be another subdir i686-linux-gnu/lib.
 
that's multilib not multiarch :)
I have /usr/lib/arm-linux-gnueabi /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu/ on this machine
and I can build and run for any of them
 
@Flexo well, multiarch is a bad name, cause it's the architecture that differs. you're strictly speaking mullti-os or multi-platform.
@Flexo do you have any lib32 or lib64's?
 
hello everyone...
 
@rubenvb I have old stuff stuck around that hasn't migrated to the new layout yet, but for the debian world everything is going that way long term and the core support is there now
 
3:06 PM
0
Q: Optimizing a code with C++ 2011 move semantics?

VincentConsider the following example code of a constant-size mathematical array : // INCLUDE #include <iostream> #include <initializer_list> // BASE ARRAY template<class T, unsigned int TSIZE> class BaseArray { public: // Constructor inline BaseArray() : _data{} ...

This guy had me at "optimizing".
 
@Flexo I wish GCC would follow. They're not as far as I know :(
For once, Debian got it right.
They previously messed up all the known triplets (probably still do)
 
any good tutorial on STL for begineers
 
when did they change the triplets?
there was some arm thing where it clashed
 
1385
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are released every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...

try there
 
STL is probably not what you mean though
 
3:09 PM
7
Q: What is the difference between the standard library and the standard template library?

kgradI keep seeing reference to both the C++ standard Library and the C++ Standard Template Library (STL). What is the difference between them? Wikipedia mentions that they share some headers but that's about it.

8
Q: What are good online resources or tutorials to learn C++

Peter SmitWhat are (good) online resources to learn C++? Preferably resources focused on programmers with experience in other (object-oriented) languages? Possible duplicates: Language Books/Tutorials for popular languages (78 votes) What is the best way to learn C++ if I have a bit of other ...

in short, the C++-faq tag
 
@Flexo the MinGW triplet was something like i586-mingw32msvc
 
@EtiennedeMartel Voting for dupe.
 
which is a horrible mixup.
 
JTA
Hi all. Q: Does anybody know if it's possible to tell VS(2010/2012) not to show red syntax error markings in a C file when you don't cast the return of malloc?
 
3:17 PM
Yay multilib cross-compiler is done!
 
pls see my this answer stackoverflow.com/a/11757290/981787, is it acceptable to this question?
 
@JTA firstly, this a C++ room, but I think we can forgive you this time. secondly, you really shouldn't do that. Thirdly, there might be... but I don't know my self
 
@JTA wait, VS wants you to cast the return value of malloc?
 
@ecatmur VS doesn't quite do C.
 
That'd be a good question on stackoverflow.com
 
3:18 PM
VS doesn't care about C.
 
JTA
Yes, VS complains if I dont (type*)malloc(etc.). I know this is C++, but I'm sure you all know how active the C room is.....
 
I knew that, but I didn't think it was that bad.
 
2
Q: Why when using in const& in the assignment disructor called , but assignment is correct

user1495181I learn that if i use in const& in the assignment (and in the called method signature) than the refereed object is extended until end of method. Employee const& getEmp(int a) { return Employee(a); } Employee const& tmpEmp = m.getEmp(10); // ... stuff //end of scope - tmpEmp val...

Need close votes
 
@AbhinavPriyadarshi I think so. It's a simple hack, and uses '/' in Bash though, so I don't know.
 
@AbhinavPriyadarshi what do you mean? it answers the question doesn't it?
 
3:19 PM
@JTA you can force it in C89 mode.
Which obviously sucks even more.
 
@AbhinavPriyadarshi you're still using % though. :P
 
JTA
Ok, thanks. The code still compiles obviously, but it's ugly with red squiggles everywhere.
 
@ecatmur he's not using the % operator though
 
@ecatmur The question mentions the % operator and makes no restrictions on symbols used.
 
% is not the operator here.
 
3:22 PM
see ya'll!
 
@JTA If it's a C file (extension .c) the compiler compiles in C89 mode, but I'm not sure if the IDE frontend does the same. Perhaps you can dig through the project configuration and explicitely mark the file as "C" somewhere?
That, or use new
or don't use new and use proper C++.
 
Can't you just disable the IntelliSense?
 
JTA
They are .c files. I'll have to see how to customize the intellisense I suppose. Again, thanks all for the help. You C++ guys are OK after all :P
 
No, don't go! You got the wrong impression. We're really mean! I swear!
4
 
JTA
haha
 
3:26 PM
lol
 
I got my coffee. Shit got real.
 
After a configuration/target has been created is there a way to force visual studio to copy the settings from an existing configuration/target?
 
@Tocs you don't get it, we'll only offer VS advice if you give us an opportunity to rag on VS while doing it :)
 
@ecatmur "we"?
 
@JTA “C++ guys“?
 
3:34 PM
@RadekSlupik Yeah, that excludes @Cicada and @Xeo.
(Me so funny)
 
And me.
 
@EtiennedeMartel “guys” can be sex-unspecific
 
Oooh.
 
Oooh, now you get it.
 
3:37 PM
You know, a bad joke becomes funny after 33 times. Because then it's a running gag, and running gags are always funny.
 
I think 69 times.
Not 33.
 
@R.MartinhoFernandes Noooooo
 
I suppose I should forget using any ide and instead cobble my code together via magnets and vacuum tubes circa 1970.
I'll write everything to floppies and send them in the mail to be stored in a safe deposit box
 
3:42 PM
Does vim have autocomplete?
I've only ever used vi and it was a horrible experience
 
try ed
 
unpopular opninion:
VS is a good IDE but a bad compiler.
 
It does a pretty good job at being an IDE, but configuring things is a nightmare and I have no idea about the compiler performance
 
JTA
@KonradRudolph Sorry, was AFK. Thanks for explaining to Radek. Side note: I'm a bioinformatics guy as well (saw your profile).
 
all I really want is something that won't turn the screen into a mass of red squiggles when I use C++11
 
3:45 PM
It does C++11 just fine
 
Idea for a language: If a class has no state, it is automatically transformed into a Singleton class, and calling the constructor always yields the same stateless Singleton object :)
 
you funny
 
@FredOverflow thats a bad idea.
 
@yurikilochek ...because?
 
save you from having globals
like with functors
 
3:46 PM
When exactly do you make a class without a state and get an instance of it.
 
@FredOverflow the point of singleton is to keep single copy of some state. if there is no state than how is it different from a set of functions?
 
@Tocs all the time
type tags, functors, ....
 
@yurikilochek Singleton objects can implement interfaces, so you can use them polymorphically.
 
@FredOverflow, ah i see where this idea come from now.
might ondeed be usefull for stuff like dependency injections
i*
 
@FredOverflow That only makes sense for reference-y languages.
It makes no sense for value-y languages, like C++.
Hope I made that clear. I'm not sure how I should call the two sides of this divide.
 
3:51 PM
sure, just call new :)
the semantic-y divide?
 
we need a new tag for this
 
Is there a name for that?
 
21 flags! What is the PHP room up to?
 
Also, are there any other languages that behave the same as C++? D, I guess; what else?
 
3:53 PM
semantical dichotomy © 2012 by me
 
@ecatmur No, D is C#-like in this.
 
C!!!
 
ah, Pascal.
 
@ecatmur arent classes references there?
 
googling "languages with value semantics" wasn't helpful
 
3:56 PM
7
Q: Self delete an object in C++

Bình NguyênI wonder if the code below is run safely: #include <iostream> using namespace std; class A { public: A() { cout << "Constructor" << endl; } ~A() { cout << "Destructor" << endl; } void deleteMe() { delete this; co...

1
Q: length of dynamic array in c++

JatinI declared a dynamic array like this: int *arr = new int[n]; //n is entered by user Then used this to find length of array: int len = sizeof(arr)/sizeof(int); It gives len as 1 instead of n . Why is it so?

one more close vote please, both are at 4 now
@Prætorian What a terrible question.
 
@FredOverflow And a duplicate of one he himself asked yesterday :)
 
lolwut? He must have amnesia.
 
@Etienne recognize it? ;)
 
@R.MartinhoFernandes How about man languages (C++) and sissie languages (the rest)?
 
3:58 PM
^
 
@FredOverflow Sexist.
 
@R.MartinhoFernandes I know this.
 
@FredOverflow can't a c++ implementation do what you're talking about already in most cases by that rule (can't remember the name) that there is no observable difference?
 
@R.MartinhoFernandes Aren't both men and sissies male?
@KeithLayne Are you talking about the empty base class optimization?
 

« first day (655 days earlier)      last day (4296 days later) »