« first day (452 days earlier)      last day (4488 days later) » 

7:00 PM
Looks because the compiler won't inline my code as much as it does std::map. Or so I'll tell myself
 
3
Q: transfer loop into C++03 for_each

FredOverflowI have the following traditional C++03 loop (using auto for stack overflow space efficiency only): for (auto it = some_vector.begin(); it != some_vector.end(); ++it) { foobar.method(*it); } In C++11, I managed to rewrite this into the following for_each invocation which works perfectly wel...

found a duplicate to my question, please vote to close
@JohannesSchaublitb What did the dentist say/do?
 
@FredOverflow he cleaned my teeth xD
and said the pain will go away in some days
 
So no huge operation necessary?
 
he said. let's see whether he's right
 
That's great. Do you have pain medication?
 
7:09 PM
no
it doesn't cause much pain. only sometimes a little.
 
Which tooth was it, a Backenzahn?
 
yes
Weißheitszahn
 
@Grizzly boost::flat_map uses a linear search for find. It's hard to imagine that beating std::lower_bound even for 16 elements. It might though. I'll see.
 
cache effects might be the winner there
 
flat_map?
is this one a new class?
 
sbi
7:21 PM
 
@JohannesSchaublitb Ah, so that's where you get all your wisdom from! I only have one.
 
@JohannesSchaublitb When I went to the dentist my teeth were aching. I thought I was in big trouble but the dentist just cleaned the "tooth-stone" which led to heavy bleeding of the flesh at the base of my teeth. He said I needed to brush closer to the base of my teeth and that my tooth flesh was inflammated due to the tooth stone and that caused the bleeding. I followed his advice and it healed in a week. Now my teeth no longer bleed even if I brush on the flesh.
 
7:25 PM
Also, flossing is a good idea to prevent tooth problems.
I floss 2-3 times a week. Every day would be better, but I'm too lazy :(
Why is every 2nd Channel9 video about Kinect? Is there really so much to say about it?
 
@FredOverflow I floss every day. Twice a day when my girlfriend is supervising
 
I have never flossed in my life.
 
Twice a day isn't possible for me, because after flossing, using my teeth hurts for a few hours, so I can only do it before sleep.
 
I don't even know where to buy floss thread/tape.
 
Apotheke, don't know the english word :)
 
7:29 PM
it's the drug store
 
Apotheker in dutch :)
Pharmacy in English.
Apotheker in dutch :)
 
Practically every drug store should also have it.
 
Pharmacy in English.
 
@StackedCrooked or really any store that sells groceries.
 
chat hiccup :(
 
7:30 PM
you can ask your dentist to close the room between teeth then you don't need to floss anymore
 
cost?
 
I hate using a linear search even when I know that's best for my intended data size :(
 
lol i was kidding
 
@FredOverflow 60 minutes?
 
I imagine that wouldn't be too healthy, because teeth normally move constantly.
 
7:31 PM
You can also replace your teeth with fake ones.
 
if you put them together they don't move anymore
which is better anyway
 
@MooingDuck Linear algorithms are great for up to about 30 items usually.
 
Xeo
Btw @Johannes, mind replying to my last comment here? :)
 
@FredOverflow for my case, A linear search is beating std::lower_bound up to about 100 items.
 
@JohannesSchaublitb Finally we have move semantics, and you want to stop moving??
@MooingDuck Hello cache effects.
 
7:32 PM
@Xeo curiousguy already told ya
 
@FredOverflow if that was the case, why was std::map outperforming std::lower_bound on a std::vector?
 
You could replace all your teeth with implants, then brushing teeth and flossing wouldn't be as essential :)
 
(in his answer)
 
Stupid question, random nonlinear access
 
@MooingDuck dunno
 
7:33 PM
> "blablabla if blobloblo" blobloblo does not apply, so blablabla does not either.
(and in that comment)
 
@FredOverflow my conclusion was pointer arithmetic actually, since that's really the only difference when you have less than 100 elements
 
Are you saying pointer arithmetic is slow?
 
slow is relative, my friend
 
@FredOverflow slower to calculate the midpoint than to follow the "next" link, yes
 
Time flies when you're having fun.
 
Xeo
7:36 PM
@JohannesSchaublitb I still don't get it. He even quotes the exact same paragraph at the end of his post.
 
@MooingDuck Calculating the midpoint is only 3 operations.
 
@FredOverflow and yet std::map::find is faster than std::lower_bound on a std::vector for the same 16 elements with the same comparitor.
 
@Xeo i don't know how to explain it to you
he seems to have explained it like I would
 
@FredOverflow I had a bug, linear search beats my binary search to about 50ish elements
 
Xeo
@JohannesSchaublitb The paragraph can be read as "if there are to-be-deduced template paramters inside a templated function parameter, implicit conversions are not performed". That only seems to strengthen my point.
 
7:41 PM
Can we see your binary search? Most implementations are wrong :)
 
@FredOverflow std::lower_bound
 
@Xeo no it cannot be read that way
and his answer shows why
 
@FredOverflow ideone.com/i00hs where internal_ is a std::vector
 
you cannot change a random standards paragraph in a random way and then deduce something from it. by the time you have changed the random standards paragraph, it becomes your standard. It is not the ISO Standard anymore.
 
A map has no duplicate entries, so of course find will be faster, because it will stop as soon as it finds the element. Vectors, on the other hand, can have duplicates, and lower_bound has to find the first of those, so there is more work to do.
 
7:44 PM
@FredOverflow MSVC10's std::map::find is a call to std::_Tree::lower_bound followed by some code to return end if result isn't an exact match.
iterator _Where = lower_bound(_Keyval);
return (_Where == end()
|| _DEBUG_LT_PRED(this->comp,
_Keyval, this->_Key(_Where._Mynode()))
? end() : _Where);
 
So? Just because it is also named lower_bound doesn't mean it does the same thing as std::lower_bound.
 
@FredOverflow I checked. It does, just with different logic for finding the next left/right node
 
The lower_bound is easier to determine when there can be no duplicates, and trees have no duplicates.
 
what do you guys think about one line loops, use braces or not?
 
@FredOverflow yeah, because _Tree is also used by std::multi_map.
 
7:46 PM
@MooingDuck Really? So it doesn't stop as soon as it finds an element?
@bamboon Do whatever your coding standard tells you to do. If you work alone and have no coding standard, feel free to do whatever you like.
 
@Xeo i recommend you if you want to know why you quoted the wrong paragraph, you make a SO question quoting the comments @curiousguy did. perhaps other ppl can explain better than him and me.
 
Xeo
@JohannesSchaublitb Okay, "no implicit conversions other than derived-to-base conversions". Would that be correct?
 
@FredOverflow well yeah, makes sense
 
you cannot base it off that text paragraph. it does not say such
 
@FredOverflow I read it several times, std::_Tree::find doesn't stop if it finds an exact match. Because of the way predicates work, it's easy to show that would be slower at least 50% of the time, and from there, slower on average by a large margin.
@FredOverflow oop, gotta go, meeting GF for lunch
 
Xeo
7:55 PM
@FredO: you might want to unaccept my linked answer, as I generally trust @Johannes' judgement, though I just can't seem to wrap my head around to why that paragraph isn't explaining what's happening. The other paragraphs mentioned by curiousguy only seem to allow specific cases (some pointer and derived-to-base conversions), and in all other cases, that paragraph should apply. In my theory, at least.
 
@Xeo What answer?
 
the paragraphs that @curiousguy quoted allow only specific cases.
not only allow, but allow only. That is, all other cases are forbidden
 
@MooingDuck In that case, I have only one explanation left for the strange performance characteristics, and I'm afraid it involves wizards :(
 
"However, there are three cases that allow a difference:". for all the other cases, the mismatch will result in deduction failure.
 
Xeo
@FredOverflow this one
 
7:58 PM
@Xeo I cannot un-accept an answer on @KerrekSB's question, sorry :)
 
Xeo
Oooh, I somehow thought that was yours xD
Sorry, so it's @Kerrek then. :)
 
I hate the hungarian notation.
 
the text you quoted just says that in template<typename C> void f(C);, you can say f<string>("foo"); and it just works (conversions happen). Because during deduction, the function type is "void(string)", because the C is replaced by the explicit argument before deduction happens.
 
Xeo
@JohannesSchaublitb "In general, the deduction process attempts to find template argument values that will make the deduced A identical to A [...]. However, there are three cases that allow a difference: " Those "three cases" should apply to the sentence before that, aka when the deduced A will differ from the transformed A. That doesn't seem to relate to the rest of the argument deduction process.
 
in c++03 it was underspecified that the same happens also for template<typename T> void f(T, typename identity<T>::type *); f(0, 0);`. some compilers rejected that. in c++11 they are all required to accept this - text was added in 14.8.2.1p4.
"[Note: as specified in 14.8.1, implicit conversions will be performed on a function argument to convert it to the type of the corresponding function parameter if the parameter contains no template-parameters that participate in template argument deduction. Such conversions are also allowed, in addition to the ones described in the preceding list. —end note]"
it refers to the text you quoted
but this is only in one direction. it does not mean that if there are parameters that participate in deduction, that then no conversions are allowed. that would directly contradict 14.8.2.1, as @curiousguy said
 
8:04 PM
@FredOverflow What happened?
 
Xeo
@KerrekSB This here. I somehow thought the question was from @FredO
 
Oh, why is Curiousguy suspended? And why has it been so peaceful of late?
 
@Xeo And since the question was well-phrased, I feel somewhat honored to have been mistaken as @KerrekSB :)
 
Xeo
@KerrekSB He's already been suspended since mid-december IIRC
 
@FredOverflow perhaps you can explain to @Xeo what happens
 
8:06 PM
@Xeo The easing of pain is never felt as much as its onset, I suppose.
 
apparently @curiousguy is very direct in what he says
 
@JohannesSchaublitb What?
 
and sometimes he doesn't seem to be interested in helping others, but just pet his big EGO
 
@Xeo So you want that question unaccepted? I did struggle accepting it, but ultimately convinced myself that the reason is that operator< is a template.
 
Is curiousguy the same guy as "There is nothing we can't do"? Because I haven't seen that guy in a long time.
 
8:07 PM
@FredOverflow no that's a different guy
 
Xeo
@FredOverflow No
 
@JohannesSchaublitb Direct is something else. I think I'm often quite direct. "Pugnacious" would be a more apt term I'd use.
 
I'm pretty direct in what I say
 
@DeadMG Yeah - but rarely aggressive, and usually right
 
8:09 PM
I appreciate the right part, but I think you underestimate how aggressive I am
 
Anyway... so I think ultimately it just came down to a nondeducible context,...
 
or maybe I just overestimate it
 
Xeo
@KerrekSB Yeah, as my reasoning seems to be the wrong way around
 
@DeadMG is a language nazi.
 
... like in template <typename T> void f(typename T::type).
 
8:10 PM
Blech. I'm confused over when to use asserts and when to throw exceptions.
 
@KerrekSB no it's not a nondeducible context
 
nah
 
The numerous answers to the numerous SO questions all seem to disagree with each other.
 
@Maxpm Assertions are for debugging only
@Maxpm I think I actually answered a literal SO question like that at some point
 
I just have a high, high bar for the quantity of control that's acceptable- a lot higher than most of the other users of the channel
 
Xeo
8:11 PM
@Maxpm asserts are for coding errors, exceptions are for user errors
 
omg... I just went from a horrible day to rep-cap... Sometimes Java just amazes me on SO.
1
Q: What is the difference between != and =! in java?

Prometheus87I was looking over some mock OCJP questions. I came across a really baffling syntax. Here it is. class OddStuff { public static void main(String[] args) { boolean b = false; System.out.println((b != b));// False System.out.println((b =! b));// True } } Why does ...

 
> Every language other than C++ sucks because it is not C++, and C++ sucks because of its many shortcomings (that WideC will fix, of course).
 
Xeo, Johannes: I'll just let this percolate a bit. I admit that this question had me pretty confused and that I still can't claim that the answers fully convince me, but we can revisit that later.
If you have anything to add, feel free to edit to heart's content.
 
@Xeo Well, if I have a game of connect four, and the user somehow tries to place a piece in a column that doesn't exist, is that a user error or a coding error?
You could argue it's the programmer's fault for not checking that the index is valid.
 
@FredOverflow I hear they're using WideC to write Half-Life 2 Episode Three
 
8:12 PM
@Mysticial TIL
 
Xeo
@Maxpm Coding error, how would he be able to without one?
 
reference_wrapper<T> does not match basic_string<A, B> and only 3 cases allow a difference but none of the cases can make them match.
 
@Xeo And user errors only, not "expected but invalid user behaviour"
 
@sehe That they may do, but I am going to carry on blissfully ignorant of any potential ass making I may have done >_<
 
Xeo
8:13 PM
@KerrekSB You should rather emphasize only
 
@JohannesSchaublitb LORE
 
@JohannesSchaublitb YES
 
@Xeo Reemphasized!
 
@KerrekSB How are you supposed to write exceptions for unexpected conditions?
 
Xeo
8:14 PM
@JohannesSchaublitb What's the paragraph I quoted good for anyways then?
 
@innuendoreplay Hello.
 
@Maxpm You have, in decending order of locality: 1) valid user input (program proceeds along hot path), 2) invalid user input (program proceeds along cold path), 3) critical runtime error (throw exception, recover higher up if possible), 4) broken code (fix at home).
@Maxpm You don't write exceptions, you throw them. There are enough predefined exceptions already to last you a lifetime.
 
hello maxpm
 
@KerrekSB I meant throw. Sorry for the miscommunication.
 
here the people doesn't talk?
 
8:16 PM
The point is that dealing with expected, but invalid user data is part of the main program flow, and not exceptional behaviour.
An exceptional situation is something like a file IO error, or being out of memory.
 
@innuendoreplay Quite the contrary. We're probably the chattiest room on Stack Overflow.
 
Xeo
@KerrekSB Err.. I'm more the fan of writing your own exception classes that simply derive and forward to the std ones, to allow better filtering of exceptions and to have nice names when they get through.
 
@Maxpm And the starriest!
 
Xeo
@KerrekSB Maybe not so much on a console
 
@Maxpm Use throw
 
8:17 PM
what??
hehehe, less activity
 
Xeo
@innuendoreplay No, we write.
Talking would be kinda useless.
 
what platform do you like to use for develop?
 
Alright. Here's another scenario.
 
Let's say I'm writing a library.
 
8:18 PM
@innuendoreplay Windows
 
about what?
 
The "user" of that library is the programmer.
 
Xeo
@Maxpm assert(this_library.author != me);
2
;)
 
can std::vector have more than two template parameters?
all other optional?
or is this illegal
 
8:19 PM
hey guys, are you spend all the day programming
 
Do I throw exceptions when I get invalid arguments, or assert that they are valid?
 
Xeo
@JohannesSchaublitb I believe there was that question on SO and the standard says that it might have optional ones, somewhere.
 
hey guys, are you spend all the day programming?
 
(Man. What is with my typing today?)
 
@JohannesSchaublitb Why would you care, are you writing your own implementation of the STL?
 
8:19 PM
?
 
@innuendoreplay Pretty much.
 
@FredOverflow just wanna know -.-
 
Xeo
@innuendoreplay No, we waste all day on SO
 
@Maxpm It depends. An assertion is mean to indicate a programming error. An exception signals a runtime error.
 
so that in nerd discussions i can chime in
 
8:20 PM
@innuendoreplay No, we spend most of the day chatting about programming.
 
Only you can decide which is which.
 
Blech.
 
my parser throws an exception to indicate malformed input
 
in SO doing what?
 
I've rewritten this same set of functions, like, five times now.
 
8:21 PM
Which functions?
 
@DeadMG How do you handle it?
 
print the message to the console atm
 
@FredOverflow Just some stuff for a Java implementation of connect four.
 
@DeadMG I mean, do you carry on, or do you terminate?
 
terminate ATM
 
8:22 PM
there is always a sensible choice for what to do when carrying on i think
 
I see. Then an exception is perfectly apposite. It signals a situation that does not allow you to continue normal operation.
 
Xeo
Which is about the only option if you only handle exceptions at the top-level in main.
 
Basically, you can "feel" when you're Doing It Right.
 
hooo, why you rewrite your functions @Maxpm are you developing a critical library?
 
Have fun implementing parsing tolerance (what's the right term?). Otherwise nobody will use your compiler.
 
8:23 PM
@FredOverflow Recover at the next statement?
 
@innuendoreplay Because I can't decide how to handle bad indices. I keep flipping between exceptions and asserts.
 
Wait, he has no semicolons.
@Maxpm You're asking the wrong question
The question is, "where does the index come from"
 
right
 
Parsing correct code is relatively trivial. Parsing incorrect code is an art form.
 
hehe, little confused hehehe, are you a team=
?
 
Xeo
8:24 PM
@Maxpm assert and constrain index input otherwise.
 
If your own code computes the index, then a wrong index is a programming error. If the index comes literally from the user, then it's a normal condition that you must handle.
 
Xeo
Imho
Since the rows / cols of the grid are fixed
 
damn
SK-logic is a fucking idiot
 
> No free variables. I consider any language "functional enough" if it is possible to define Y-combinator (properly, not your way).
a Y-combinator is a Y-combinator is a Y-combinator
 
8:25 PM
my language has a Z-absorber
 
How about a gamma radiator?
 
Xeo
I don't get what Y-combinators are all about. :(
 
It's some fundamental FP thing.
 
@KerrekSB In this case, the index will be calculated from a user's mouse click position. My own code will pass it all the way from the GUI to the bare-bones logic class. I'm designing the latter as if it were a public API, though, if that matters.
 
well
 
8:26 PM
?
 
apparently, my Y-combinator isn't good enough because I used some member variables
 
In computer science, a fixed-point combinator (or fixpoint combinator ) is a higher-order function that computes a fixed point of other functions. A fixed point of a function f is a value x such that x = f(x). For example, 0 and 1 are fixed points of the function f(x) = x2, because 0 = 02 and 1 = 12. Whereas a fixed-point of a first-order function (a function on "simple" values such as integers) is a first-order value, a fixed point of a higher-order function f is another function p such that p = f(p). A fixed-point combinator, then, is a function g which produces such a fixed point p for...
Y g = g (Y g)
> In programming practice, the Y combinator is useful only in those languages that provide a call-by-name evaluation strategy, since (Y g) diverges (for any g) in call-by-value settings.
@R.MartinhoFernandes So is Haskell's fix a Y combinator?
 
@Maxpm Then your UI should determine whether the click is valid or not, and probably just discard it if not.
 
@FredOverflow Yes, I believe so
 
@FredOverflow Spline reticulator?
 
8:27 PM
although I understand the function of what I've written, and I know it's a Y-combinator, I have no idea what the fuck the fixed-point thing is for
 
@DeadMG fix allows defining recursive functions anonymously, as an expression
 
eh
I don't see how
 
hey all
 
has anyone here done some work on a SMTP server
 
I did re-invent fix in C++ :P
 
congratulations :)
 
well, not really
 
Couldn't you argue, though, that every invalid index is beyond the given module's control? Let's say I take away the GUI part and just have my logic class. It has no idea what's being passed to it, and it's expected that some arguments will be invalid. Why wouldn't I throw exceptions for that?
 
no
the definition of unexpected is invalid
 
8:36 PM
I disagree. I have an array with ten elements. Accessing array[10] is invalid, as is array[11], array[12] and so on, but I expect someone to try to do just that.
 
@Maxpm It's never an exception. An invalid click is a normal operation, so it has to be handled like that. Either you specify your library to require valid input, in which case it's an assertion in your code (client wrote it wrong), or you handle it in your code (e.g. discard it silently). But in the latter case you would take mouse coordinates as input, not indexes. If you're getting cooked indexes already, tell the cooker to give you only valid indexes.
 
Hmm.
Aren't exceptions for arguments originating from external sources, like user input, the operating system, the network or another program?
I consider things outside the library to be external.
 
Xeo
@Maxpm Depends on your API
Like said, if you only accept indices, it's a coder error to provide invalid ones
If you accept mouse positions, discard invalid ones
@KerrekSB *indices
Wait, I just noticed that "indexes" is also valid.
 
@Xeo Doesn't the C++ standard library throw exceptions on that kind of thing?
 
Xeo
@Maxpm If you use at, which is like explicitly asking for bounds checking
 
8:49 PM
It uses assertions on the subscript operator?
 
Xeo
@Maxpm Well, some implementations do in debug mode
 
Hrmm.
I'm more confused than ever.
 
Xeo
Because in C++, out-of-bounds access to a C style array is UB and not checked, and they want to mimic built-in types as closely as possible
 
People draw the line between them in so many ways.
Runtime versus compile-time... User versus developer... External versus internal...
 
9:17 PM
Does anyone have some examples of assertions and exceptions used correctly in real code?
 
@FredOverflow wouldn't fix just be a plain lambda?
 
@Maxpm You're overthinking this. Moving the mouse is what the mouse is for, so it shouldn't cause an exception. no matter which way you skin the cat.
You can thrown an exception if the mouse explodes.
3
 
onExplode() oh, that would be when the Explode event is generated.
throw OutOfMouseException;
hi @CatPlusPlus
did you just get up?
 
It's just that they, as far as I can tell, do the same thing. Assertions are a little less verbose. Everyone seems to define the distinction differently.
 
No, I just came home from the test and post-test beer.
 
9:27 PM
oh
and how was the test?
 
Probably not so good, but possibly not terrible either.
 
Any incoherences are to be attributed to the beer talking.
 
oh, you drunk?
 
@KerrekSB Hey, no cat skinning, eh.
You monster.
 
9:29 PM
lol
 
@TonyTheLion A tiny bit.
 
oh not too bad
 
I didn't eat much today.
Well, I still know how to write English properly.
That's something.
 
@CatPlusPlus Relax. Don't cats shed their skin every couple of months anyway?
 
quite an achievement :P
 
9:30 PM
@KerrekSB in a carefully controlled manner
 
they shed their fur
not their skin
different thing
mmmmmhhhh eating snickers...
 
Hi
 
@kbok you're the guy who got me all the rep!
21
Q: Array placement-new requires unspecified overhead in the buffer?

Mooing Duck5.3.4 [expr.new] of the C++11 Feb draft gives the example: new(2,f) T[5] results in a call of operator new[](sizeof(T)*5+y,2,f). Here, x and y are non-negative unspecified values representing array allocation overhead; the result of the new-expression will be offset by this amount from ...

 
repwhores
 
@MooingDuck Yeah, I saw that. I first thought that I should be the one deserving all those boats, but to be honest I wouldn't be able to formulate that question as clearly as you did.
 
9:33 PM
@kbok I wasn't either, look at the edits :D FredOverflow wrote most of it
 
@MooingDuck Oh, right :p
 
I have 30k useless rep, woo.
 
Anyway, you went through the trouble of writing it. That's an effort I couldn't afford :)
 
@maxpm I came late to the party, but read back some of the discussion. Assertions are for debugging. They're not intended to make it through to the final product. Exceptions are final product error handling suckas.
http://www.cplusplus.com/reference/clibrary/cassert/assert/
 
@CatPlusPlus now you can go downvote everything
 
9:36 PM
 
Don't link to cplusplus.com.
 
@finity I think I understand.
 
Also, assertions are for assumptions.
 
@CatPlusPlus I'm not normally a fan either
 
Anyway. I'm looking for a container looking very much like a vector, but which can't be resized after construction. Any ideas ?
 
9:37 PM
@CatPlusPlus I love asserts. I have asserts everywhere. They keep me from making stupid mistakes
 
I filed my own gcc bug report - yeeha :)
 
@kbok std::array? or custom type
 
I'm thinking of subclassing a std::vector, but that would break LSP
 
@kbok Why?
Wrap, don't subclass.
Or just don't resize the vector.
 
9:38 PM
@CatPlusPlus Think of it like noob downvote buffer.
 
@MooingDuck array has its size defined compile-time, right ?
 
@kbok yes
 
 
@CatPlusPlus That would be a pain, but yeah it's still better.
 
@kbok else you'll have to make a thin wrapper
 
9:40 PM
@JohannesSchaublitb Would you have any thoughts on how to reduce this bugs minimal testcase (gcc.gnu.org/bugzilla/show_bug.cgi?id=51829)? It is pretty small, but in preprocessed form it is still considerable.
 
@Maxpm The term for that is Pokemon Exception Handling.
 
@kbok it's not that bad actually. I wrapped a vector to give it a map interface and that was easy. (Just not as fast as I hoped)
 
@CatPlusPlus In my company the code you write can be modified later by anyone working on something related to it. I don't want people seeing vectors and screwing around my code resizing them.
 
template <typename T> using fixed_vector = std::vector<T>;
 
@kbok change jobs? expose iterator ranges? (it is called encapsulation and has been OO hibby for quite some time
 
9:42 PM
@sehe Oh come on. Everytime people complain about any tiny thing in his/her company he's told to quit.
 
@kbok No. You have to be able to trust coworkers. Or have review processes in place. That is non-negotiable :)
 
I've got one of the best positions of all my prom and actually one which I wouldn't be able to get with my education. I'm not going to switch because people could resize my vectors.
 
Quit all the jobs!
 
@kbok For the record, I'm with the same company for 14 years and counting. I complain a lot, but I won't go and subvert pragmatic programming style just to avoid to fix things/straighten collegues out, or because I'm so possessive about 'my code'
 
@sehe We have review processes, but I don't trust people outside of my team :)
 
9:45 PM
That's what git log is for...?
 
@sehe What do you mean ?
 
O. M. G. What do 'the (eee) people (ooo) outside of my team' (with scary paws?) have to do with 'your vectors'?
The whole notion of 'they can touch my vectors' seems... childish and a bit off-the-mark
 
Well, I certainly don't want strangers touching my private members.
;)
 
I mean, we have tests, (unit, integration, acceptance, regression, the whole lot) and they will catch any unwarranted rummaging with vectors.
And we do tell the culprits not to repeat that
@kbok Precisely. Soooo they can resize your vectors. Document it ('dont resize the vector') or... the best way is not to expose the vector. Expose an iterator range - make std::begin()/std::end() work with them and there is no need to worry
 
@sehe We have many classes with sets of data stored in several vectors. The global assumption is that they all have the same size. Is someone were to resize one of them, that would lead to errors. Surely not fatal, because we have quality process and so on, but the real problem here is that vectors carry the semantic of being resizable which is wrong.
Also I think you're being rude and insulting.
 
9:51 PM
@kbok Lol. Opinionated. Yes. Insulting? "Come on" (quoting you)
 
@sehe You're quoting from quite a different context.
Also to get back to the subject, encapsulation would be a solution, but only to clients of the class.
I also thought of a pack of vectors, which when resized would resize all the containing vectors.
 
@kbok You're worried that someone will open your class's source file to make changes and think that the private vector member variable can be resized, right?
 
But it's quite impractical in C++ I think - requiring to write very similar code for each class.
@Maxpm Yep.
@Maxpm Or that could even be me
 
@kbok I would just document it well, then.
 
@kbok Mmm not so very, but ok, rereading my messages I have to admit I'm apparently venting a bit after trying to minimize a bugreport for gcc 4.6/4.7. Sorry if that surprised you.... There was a hint though: "I complain a lot"
 
9:57 PM
If that isn't good enough, you could always make your own data structure. That kind of thing is trivial to implement.
 
use unique_ptr<T[]>?
 
@sehe Fair enough
 
+1 And learn to trust yourself.
You sound a bit to paranoid, like I used to (and sometimes still do).
Accept that you will make mistakes, but solve it by designing for simplicity and documenting the invariants.
 
@DeadMG Still constant-sized, isn't it ?
 
True, but in practice, special-casing too many things often leads to complicating the code, leading to more errors...
There is a solid reason why highlevel programming languages love their highlevel libraries: everybody knows them well, and they are designed for flexibility
 

« first day (452 days earlier)      last day (4488 days later) »