« first day (844 days earlier)      last day (4105 days later) » 

7:00 PM
@cab template function recursion is not runtime either
 
user1125394
@Zoidberg I know but learning
 
user1125394
ah ok
 
user142019
int factorial(int n) {
    if (n <= 1) return 1;
    return n * factorial(n - 1);
}
 
user1125394
yes of course.. but wanted to make it functionnal way ;)
 
user142019
factorial :: Integer -> Integer
factorial = product . enumFromTo 1
 
user1125394
7:01 PM
haskell
 
> In part 8, STL digs into the do-while loop, casts, one definition rule (ODR), and his variadic template array sorter. There is a lot of information in this episode, so get comfortable, tune in, and learn.
 
@DeadMG, it's not really possible. When you program for the sake of creating a piece of art and you ask yourself "This works, but its ugly; should I use my time to refactor it or should I just deploy it?" you always refactor, because you always aim towards perfection. Art is awesome, Tools just works.
 
well-written code is art, and code which works is a tool.
there's no reason any given piece of code cannot be both simultaneously.
 
user142019
 
@Zoidberg, :P
 
7:04 PM
@Zoidberg This band is great.
 
Dinner time
cya
 
@Zoidberg That's a strange tool, why on earth would you need the two identically sized screw drivers at the bottom?
 
@FredOverflow Har har.
 
@FredOverflow generating sperm.
 
@FredOverflow What universe has screwdrivers that look like that?
 
user142019
7:06 PM
@ShotgunNinja I've heard sperm is half full of life.
 
user142019
@ScottW inb4 sbi
 
@sehe Okay, it's not a screw driver, it's a... don't know the English word for that. Wrench?
 
user142019
You can certainly screw people with that thing.
 
@FredOverflow I'm not sure. Wrench is my best guess too
@Zoidberg Oh. Lubricate and warm before use
 
^ this is quite funky
 
7:08 PM
@Zoidberg Or Jerry.
 
auto vroom_vroom;
 
Yay. Boost finally has infinite precision integers. Something that should have been in the standard library from the start.
 
@BenjaminLindley Awesome! Finally I can solve some non-trivial Project Euler problems in C++ :)
 
@FredOverflow Spanner.
 
Thanks
 
7:15 PM
@BenjaminLindley do you know how it compares to gmp?
 
user142019
No problem
 
user1125394
 
@DeadMG That's German for "voyeur". At first I thought you were insulting me :)
 
Ell
@bamboon it can use it as a backend iirc
 
@bamboon I think by default, it's a wrapper around gmp
 
7:16 PM
@LightnessRacesinOrbit Why didn't I realize this simple thing before.. Making our externals point to an actual number instead of HEAD would solve the breakage problems entirely.
 
@bamboon No, I do not. However, it has the ability to use gmp as a backend.
 
@LightnessRacesinOrbit at your service
 
oh, that's sweet
 
@StackedCrooked yessir
 
@FredOverflow Never attribute to vocabulary what could be explained by obnoxiousness?
 
7:17 PM
@StackedCrooked What was your problem and how did you find that post?
 
@sehe Did you just invent that, or is that "common wisdom"? :)
 
@FredOverflow It's the only slight aberration from "common wisdom" that would aptly explain your line of thought there :)
 
@StackedCrooked "VROOOM VROOOM" is a good song.
 
The problem currently is that in our current codebase branches and tags are not self-contained due to many externals which can sometimes change.
 
7:18 PM
@Zoidberg That's for optimists. Pessimists would maintain that it's half empty instead
 
@MooingDuck No, it's not. Their isn't really a default, from what I can tell. You can include cpp_int.hpp to use the one built in to boost, or you can include gmp_int.hpp, or mpfr_int.hpp, and some other things.
 
user142019
@sehe "Women"
 
@FredOverflow Well.
 
@StackedCrooked poor
 
Yeah, I didn't set up the system :D
I would insist that tags are immutible. It's ridiculous now.
 
7:21 PM
rooting android phones is always harder than the tutorials want to make you believe
especially chinese ones
 
@MooingDuck I take that back. There is a default. It's cpp_int. The one built into boost.
 
user1125394
rotting them is easier
 
@rubenvb chinese phones, or chinese tutorials?
 
I just thought of a question that would practically make me immortal rep-wise: "If there is const_cast in C++, why is there no volatile_cast?" :)
 
@sehe tuts are in english, thankfully
 
user142019
7:23 PM
@rubenvb @sehe tuts? Do they teach you how to @sehe?
 
user142019
inb4 newfags can't @sehe.
 
@BenjaminLindley sad, but makes sense
 
@LightnessRacesinOrbit But my reasoning up to now was that in order to make a project self-contained we should either keep all code in the same repository or we should set the set tags to a fixed revision number when making a branch.
 
@Zoidberg nobody can @sehe. Not even the Spanish inquisition
 
But your suggestion does away with the problem before it even matters.
 
7:24 PM
@BenjaminLindley this seems to indicate that the types aren't generic which I find pretty lame
 
@FredOverflow Because const_cast does volatileness too?
 
user142019
@sehe that's why there are tuts on how to, so somebody can learn it.
 
@DeadMG I honestly didn't know! Suspected it, though. Maybe cv_cast would have made more sense then?
 
@FredOverflow It's more of a trivia than a useful thing to know.
 
user142019
7:25 PM
@FredOverflow noob
 
user142019
EVEN I KNEW!
 
@Zoidberg Noob rimes with boob, so I'm fine with that.
 
user142019
. (.) . noob operator?
 
@StackedCrooked some of my team don't like it because they have to keep updating the externals, and some of our dependencies get updated quite frequently. I say that it's good that that gets harder.
 
user142019
7:26 PM
Also, (.) (.) should be valid too, and looks much more like boobs than ((.).(.)).
 
not all overhead is bad
 
user142019
Unless your bellybutton is really high.
 
@bamboon I don't know about the infinite integer type, I'll have to investigate a bit more. But the limited integer types (128, 256, 512 and 1024) are definitely generic.
 
@bamboon or that cpp_int merely instantiates the generic type with the cpp backend.
 
user142019
But yeah, prefix . is silly.
 
7:28 PM
@MooingDuck You mean, like this?
but vastly overcomplicated?
and a duplicate of every scope_guard class ever?
and worthless, just like them?
 
user142019
 
@MooingDuck When will Java for MSVC10 be ready?
 
user142019
Lambdaless (.) implementation!
 
@Zoidberg But the classic boobs are actually useful:
 
7:30 PM
@DeadMG yes
 
myConcatMap = ((.).(.)) concat map
 
@DeadMG worthless? I disagree with that
 
I see that it's trendy now to postpone includes until they are used for the first time. I shall take note.
 
@MooingDuck Worthless in the sense that Boost had them for a while now IIRC
 
@ScottW What makes you think that? Also, why would it matter?
 
7:31 PM
@sehe Any implementation of a worthless concept is just as worthless as any other.
 
His brains.
 
@DeadMG there is a functional difference but not relevant to the discussion.
@DeadMG I find it useful, I dislike making a seperate class for each function I need to happen after the "important" function.
 
@ScottW You can compile pretty much any language into C (or into any other language, for that matter).
 
^ This is several shades of nice. I think I might just -for-fun- one day think of an excuse to play with lego like this
@DeadMG Yes. Any redundant statement is redundant.
 
@MooingDuck If you need it so often that one-shot structs are annoying you, you're doing RAII wrong.
 
7:33 PM
@DeadMG it's not RAII. I have one for adding two integers, one for subtracting, and one for balancing my tree, and another for printing the current state for debugging...
 
@ScottW C can be used as portable assembly.
 
@StackedCrooked people say that but I disagree.
 
A poor man's solution.
 
@MooingDuck Who cares well, it is. What comes closer?
 
@MooingDuck You're darn tootin!
 
7:34 PM
@sehe nothing. But there's several ops that ASM can do that C can't (as efficiently). Accessing the high bits of a 64bit*64bit, various flags, I assume there's others.
 
Well, keep on disagreeing
@MooingDuck Huh. Turing flew right past you, I'm guessing
You're saying assembly language can do some stuff with less overhead, so C isn't a portable substrate for higher level languages? Well.
Somehow, you've taken that analogy to strictly imply there must be zero overhead. Nobody claimed that. And it certainly wasn't the point here. Portability and low-levelness was the point
 
@sehe I never said that. I said C shouldn't be called "portable assembly".
 
@MooingDuck That's what you meant to say, perhaps.
 
@sehe I agree with that. I definitely misspoke at least once during this conversation.
 
7:38 PM
@MooingDuck :) Clarified.
 
Heyy! Someones being taking my old answers and downvoting it.
Not that I care about the points, but it is really annoying that someone hates me to this level...
 
@AndréPuel The system usually detects such behavior, and you will get your rep back automatically.
 
Please tell me, why would I ever have to need to const_cast something to add const?
 
@Bartek templates?
 
@BartekBanachewicz I think you need it to get rid of code duplication in operator[] const and non-const overloads.
 
7:44 PM
ok.. I have a method that receives a string as parameter. and I have vector<char> vect.

I'm trying to pass the vect.at(i) to the method, but it doesnt accept. I've tried changing the signature of the parameter to char*, but nothing..
 
@BartekBanachewicz Implementing a non-const method in terms of the const version.
 
@rogcg these two are different types
static_cast<const GLchar**>(const_cast<const char**>(&as_lvalue(m_VertFileData.data())))
 
but how do I convert the value from vect.at(i) to std::string?
 
@StackedCrooked Which movie would that be? "Fargo" is my best bet, but as YT comments go, this is a particularly tricky guess
 
@rogcg copy it to string
 
7:45 PM
@sehe Yep, it's Fargo.
 
35
Q: How do I remove code duplication between similar const and non-const member functions?

KevinLet's say I have the following class X where I want to return access to an internal member: class Z { // details }; class X { std::vector<Z> vecZ; public: Z& Z(size_t index) { // ... // massive amounts of code for // validating index Z...

Hm, the const is added with a static_cast.
 
@FredOverflow added.
 
@FredOverflow added
 
8
Q: C++ difference between adding const-ness with static_cast and const_cast of "this" object?

CaseyAs per Scott Meyers, to prevent repetition of code in the const version of a getter and the non-const version of a getter, call the const version of the method from the non-const version: static_cast<const A&>(*this).Methodology(); however, in accidental usage due to an overzealous Visu...

@DeadMG I know, I thought it was both removed and added with const_cast. @BartekBanachewicz
 
7:46 PM
but FFS why the hell I have to ADD const
 
@FredOverflow Nope. You can add const or volatile at any time implicitly.
 
@EtiennedeMartel I'm not in university anymore, but I still got that feel.
 
@BartekBanachewicz you mean myStr.copy(vect.at(i)) ??
 
@BartekBanachewicz Are you seriously asking why one would want to remove const?
 
@BartekBanachewicz overload selection. I bet using explicit const cast might select a different overload (e.g. void foo(int&); void foo(int); int i = 42; foo(i); foo(const_cast<int const&>(i);)
 
7:47 PM
@rogcg copy(vec.begin(), vec.end(), back_inserter(str));
 
damn
I ballsed up my semantic analyzer again.
 
what if I use assign?
 
@FredOverflow it's a good question. There is rarely a good reason. Think of the UB
 
sorry
2 mins ago, by Bartek Banachewicz
static_cast<const GLchar**>(const_cast<const char**>(&as_lvalue(m_VertFileData.data())))
^ this
 
@sehe The valid reason to cast away const is to call APIs that were written by morons.
 
7:48 PM
@sehe that makes sense
 
@FredOverflow That's the top #1 of the single-item list :)
 
The code I posted works without const rambling on ICC, breaks build on MSVS
So which one is in error?
 
user142019
@FredOverflow Or very old (read: pre-const) APIs. :)
 
Is it ever possible for function accepting const GLchar** NOT to accept GLchar**?
 
@Zoidberg How old is const now, 30 years?
 
7:49 PM
@BartekBanachewicz str.assign(vec.at(i)); since it accepts char*, should it work?
 
@rogcg why can't you use my solution?
 
user142019
@BartekBanachewicz Yes.
 
user142019
With SFINAE or static_assert and type traits.
 
@BartekBanachewicz It also doesn't work the other way around, by the way. You cannot assign a const X** to an X**.
 
@FredOverflow well the latter makes sense
@Zoidberg it's fucking C API
 
user142019
7:50 PM
That wasn't mentioned in the question.
 
Sorry, I thought it's obvious by GLchar
 
@BartekBanachewicz When in doubt, blame MSVC
 
it's the $!#%#@ glShaderSource
It's arguably the worst function in OpenGL ever
 
@BartekBanachewicz doesnt work. I want to copy a single char from the vec<char> to a string variable. your solution copies the entire vector.
 
@rogcg to copy it to where? end? str += vec[i]; then
 
7:52 PM
@Fanael You silly goose, temporary lifetime extension only works with prvalues.
 
@thecoshman darn. The internet is killing your common sense. Saying things is harsh too. Period.
 
@BartekBanachewicz yes!
 
I also have a few
const node* node::dosomething() const
node* node::dosomething()
{return const_cast<node*>(const_cast<const node*>(this)->dosomething());}
 
@BartekBanachewicz ty!
 
@MooingDuck I look at that, and my first thought is "Scott Meyers" :)
 
7:54 PM
@FredOverflow aha, I thought there was another const_cast in there somewhere
 
Ell
Is it against SO's terms & conditions to ask for help writing a bot? I'm not sure if it's legal or whatnot o.O
 
@Ell Bot for what? Lambdabot would be fine :)
 
Ell
@FredOverflow for a mmo :P :3
puzzle pirates
 
user142019
You know.
 
user142019
I've thought of writing a chatbot for SE.
 
7:57 PM
@Zoidberg already have one, in the javascript room and sandbox
 
@Zoidberg How do we know "Zoidberg" is not a chatbot?
 
user142019
That you can query for information.
 
@Ell Well, is it against the rules of that MMO?
 
user142019
Something like "@chatbot wp foobar" would onebox Wikipedia article on Foobar.
 

Sandbox

Where you can play with regular chat features (except flagging...
 
Ell
7:58 PM
@FredOverflow Not sure really, I guess so o.O
 
user142019
In fact, I have the Wikipedia part almost done already. :P
 
@Ell Then you probably should refrain from asking that particular question on SO.
 
@Zoidberg you're not alone
 
@Zoidberg Bender? What about Fry, Leela and others? Do you already have plans for those as well?
 
7:59 PM
@Zoidberg why perl
 

« first day (844 days earlier)      last day (4105 days later) »