« first day (388 days earlier)      last day (4561 days later) » 

3:00 AM
that's because you terminated too late
 
I think the 2*lambda needs to deeper.
 
it should return 1 when target <= 1
not when target == 0
 
0! = 1
1! = 1*0! = 1
Works fine only with 0 as a base case.
 
yes
but when it's not, then you get too many 2s
you've got 5! * 2^6, whereas I've got 5! * 2^5
 
Oh, so magic_fac(1) should be 2, that what you mean?
Or 1?
 
3:02 AM
this really isn't very encapsulated at all, you know, since both of us have valid fact functions that produce the same legal output on all values
it should be 2, but yours would give 4
the thing is, when you introduce the doubler
 
0! = 1 * 2
1! = 0! * 2 = 4
 
C++ is not amenable to this kind of crap.
 
whereas I've got
0! = 1
1! = 0! * 2
I guess that actually, that makes yours correct and mine wrong
maybe
I'm not sure
hah
yours invokes UB, bitch
 
3:04 AM
I think
aren't you referring to the stack-based function argument f?
 
You should capture by value.
 
Oh, right.
 
that's the problem I'm having right now
 
I just hammered the & in.
 
memory management :d
here's a question
aw, shit
 
3:06 AM
There, the two versions: ideone.com/e5vnX, ideone.com/FSJNk. Pick the one that fits your definition of "silly doubled factorial".
 
I actually don't see how to make this work
 
aah, it's not worth it
 
Fixing...
Oops, the result is wrong.
 
lol
 
3:13 AM
Silly me. Fibonacci is not with multiplication.
 
I can't make the self-referencing thing work
 
when it was on the stack of main, I just used the std::function trick
but now that won't work when in a generic function
as the value is popped off before it's used
 
user457812
Popped off jus' like Joe down on 8th street
 
3:17 AM
Hmm, weird, that's exactly half.
 
yeah, it's one 2* too little
it needs to be return 2*
yargh, ok, maybe not
 
"242) Informally, this means that basic_filebuf assumes that the mappings from internal to external characters is 1 to N: a codecvt facet that is used by basic_filebuf must be able to translate characters one internal character at a time."
 
I think that sucks. Also the formal spec seems to be wrong/meaningless. ARgh
 
@DeadMG Yay!
 
3:18 AM
my lambda solution is way cleaner than your binding crap
 
It's not my binding crap. It's stolen. From a time when there were no lambdas.
 
lol
true true
still, I think that I have indeed demonstrated conclusively that this is more than possible in C++
and it turned out to be way cleaner and easier than I expected
although significant thanks to C++11 for that
a few templates and you'd have something really quite generic
 
Yep.
You could even get to the point where you can write everything, including the doubler or the memoizer, in terms of y/fix/rec whatever you want to call it.
Someone broke my Internet.
Wait, no, it's working.
 
owned
 
Monomorphic lambdas really suck :(
They should at least let us do template lambdas or something.
Well, maybe that's not such a good idea. That would bring the template keyword into expressions.
 
3:26 AM
Also, support for local templates is scarce, isn't it?
 
I don't know. Can you use local types on templates in C++11?
 
MSVC has it
yes
 
Why was that forbidden in 03 anyway?
 
no idea
historical accident, I'd expect
 
@RMartinhoFernandes And before it was mandated, it often was available as an extension. Not so with templates, is my point.
 
3:29 AM
@LucDanton Can you enable GCC extensions selectively?
4.7 doesn't seem to support local types in templates yet. I wouldn't mind adding an extra flag to the build for this.
 
@RMartinhoFernandes AFAIK no, it's all governed by -Wpedantic.
 
Damn.
I want clang.
 
then download it?
 
@RMartinhoFernandes Do you have an example? It should work; and in fact a lambda expression introduces a local type as far as GCC is concerned.
 
@DeadMG Well, I want clang finished.
As it is it doesn't compile my code yet.
Initializer lists is a big missing feature.
 
3:32 AM
eh, I usually find the immediately-executed-lambda does that one just fine
 
Right, that means changing my code into some ugly mess.
And then changing it back when initializer lists are added.
 
I think it's just fine
but I also think that the ability to use local types in templates is far from useful
now that there are lambdas and bind, it's really not important
in fact, I can't even remember the last time I wrote a local type, and MSVC does support it
 
Well, when I have some complex return type I like to do return {blah, blah, blah}; :)
@LucDanton Oh wait, it works: ideone.com/RRNvJ
I'm doing something wrong.
 
Lambdas and local types in templates work in tandem actually. (Although whether the type of a lambda expression is local or not is formally left to the implementation IIRC.)
 
Since it's not named, it could be global.
 
3:36 AM
MSVC makes them local types too
 
So it's not like local types are obsoleted; but that we get a nifty literal syntax for them!
 
@DeadMG Agreed. But I have a bit of feature hunger when dealing with programming languages. Just knowing that I can't do it pisses me off.
 
(You can do with a local functor what a lambda expression can't do, like recursion and capturing by move, but I think that's largely academical.)
 
@LucDanton You can use a Y combinator! (Yes, I know that's largely academical too)
 
@RMartinhoFernandes Yeah, and you can solve capture by move with just std::bind, too. It's still silly that the lambda limitations are arbitrary.
 
3:39 AM
that sums up C++, really
poor design
 
Ok, maybe the last time I tried to use a local type I was still on GCC 4.5.
Or drunk.
 
or just stupid? ;p
 
@DeadMG well i just finished implementing utf8-converting facet because g++ doesn't have c++11 thing. and discovered that apparently there is no way to do it right. i mean for converting between utf16 and utf8.
code works ok so far though
even for some chinese
 
@DeadMG You can be stupid on a case-by-case basis?
@AlfPSteinbach Oh, why's that?
 
        // See C++11 footnote
        // "242) Informally, this means that basic_filebuf assumes that the mappings from
        // internal to external characters is 1 to N: a codecvt facet that is used by
        // basic_filebuf must be able to translate characters one internal character at a
        // time."
problem is "characters" refers to encoding values really
 
3:47 AM
Oh, surrogate pairs fuck things up?
 
yes
however, it works, and i dunno why
 
The fruits of my keyboard banging last few hours, codepad.org/JKEL5hlA
i didn't implement 32-bit wchar_t support. that's the case that in theory can be handled
 
OMG you were productive? Blashphemy!
 
Isn't std::mbstate_t the 'magical' fix for that 'one internal character at a time'? Not that I'm overly familiar with all that stuff.
 
3:49 AM
maybe
 
is that short for std::magical_bullshit_state_t?
 
huh, visual studio has inserted tabs in spite of my configuring it to use spaces
@DeadMG :-) yes, it comes from C library, but i'm not familiar with it
 
lol. I think it's "multi-byte state"
 
That and the weird interface to std::codecvt is scary.
 
There's some crap in cuchar that uses that mbstate_t thingy.
 
4:04 AM
There's a use for explicit in multiple argument constructors now.
 
return { foo, bar }; ?
 
Yeah. I'm not sure when it would be useful, but it's not meaningless.
 
Lots of variadic constructors are explicit, so as to at least avoid the painful, unary implicit conversions. However by that same token it disallows the syntax for multiple argument construction.
 
That's annoying. And a workaround is a bit painful.
Even with inherited constructors, you would have to write two specializations of a base just to assemble a freaking constructor.
 
Right now I'm shrugging it off with return T { foo, bar };. Which is really annoying for long types.
-> expression<operators::assign_to, expression, expression>
{ return expression<operators::assign_to, expression, expression>(
        std::forward_as_tuple(std::move(*this), other) ); }
How verbose is that?
 
4:11 AM
C++ verbose.
std::forward_as_tuple makes a tuple of references, right?
 
Can't wait until I have lvalue/rvalue *this so that I can add overloads that do the same work! Needs more boilerplate.
@RMartinhoFernandes Yes.
 
@LucDanton Can you give an example of when overloading on that would be useful?
(I don't mind if you just send me off into some paper :)
 
obviously, operator= for a start
 
@RMartinhoFernandes T& get() &; T const& get() const&; T get() &&; getters?
 
and postfix increment
both should be disallowed on rvalues
 
4:13 AM
d:\dev\test> g++ foo.cpp

d:\dev\test> g++ foo.cpp -std=c++0x
foo.cpp: In function 'int main()':
foo.cpp:7: error: '_fileno' was not declared in this scope

d:\dev\test> _
 
T& operator=(T const&) && = delete; does sound neat. Should be the default though.
As is, it's just more boilerplate.
 
You can't T& operator(T const&) & = default; though, can you?
 
Hmmm.
Don't think so.
Those signatures are a bit rigid.
A function that is explicitly defaulted shall
— be a special member function,
— have the same declared function type (except for possibly differing ref-qualifiers and except that in the case of a copy constructor or copy assignment operator, the parameter type may be “reference to non-const T”, where T is the name of the member function’s class) as if it had been implicitly declared, and
— not have default arguments.
What are the "possibly differing ref-qualifiers"?
 
The implicitly-declared copy assignment operator for a class X will have the form
X& X::operator=(const X&)
@RMartinhoFernandes Just the money: & and && :)
So I guess it works!
 
4:18 AM
There are now cv-quals and ref-quals.
And 'old'-style members have no ref-quals.
 
The exception for auto_ptr stands right there as an annoying wart.
If you delete T& operator=(T const&) &&, T& operator=(T const&) & is no longer implicitly defined, right?
 
Well, declaring any form of copy-assignment will disable implicit definition, yes. But also, I don't think that it would be legal for a & qualified form to be defined, as per my quote.
 
Oh, right.
T& operator=(T const&) & = default;
T& operator=(T const&) && = delete;
What if you grab this T, and put it as a member on a U?
What assignment operators will U get for free? Nothing?
Sounds like a boilerplate nightmare.
 
I was asking myself the same question, but for a base class (like boost::noncopyable).
 
> If the class definition declares a move constructor or move assignment operator, the implicitly declared copy assignment operator is defined as deleted; otherwise, it is defined as defaulted (8.4). The latter case is deprecated if the class has a user-declared copy constructor or a user-declared destructor.
Is this deprecated part a nod to the rule of three?
 
4:27 AM
Somewhat. It's about class invariants, just like the rule of three is.
Some of the committee wanted implicit definition everywhere that was possible; but that'd break old code (allegedly).
Since it was always possible to come up with pathological examples that would break with new implicit definition rules, this was the end compromise.
 
Ok, where is "copy assignment operator" defined?
 
Copying and moving, paragraph 17 and later.
 
It doesn't mention ref-qualifiers. So, is T& operator=(T const&) & = default; a copy assignment operator?
Oh, I guess it is, hence the note on defaulting them.
 
I think that paragraph is pretty definitive on that.
 
Right, but it says the implicity one is always X& X::operator=(const X&) or X& X::operator=(X&).
Which means you do need to repeat the boilerplate all over.
 
4:34 AM
i like to just let it return void
 
@RMartinhoFernandes No, that's paragraph 18.
 
but then you can't write delete on it
 
@AlfPSteinbach Why not?
 
@LucDanton Right, which is where it mentions the implicitly generated ones. If you put the deletion on a base class, it won't work.
@AlfPSteinbach You can delete it.
 
@LucDanton because it's not the standard copy assignment operator any more
 
4:35 AM
You can delete everything.
You can't default it though.
 
@RMartinhoFernandes But another overload explicitly defaults a form of copy assignment. Which means it's not user provided, is it?
 
anyway i found what was wrong with -std=c++0x for g++
it defines a macro symbol called __STRICT_ANSI__
 
@LucDanton But it's boilerplated.
 
and one must use the -U option to tell the compiler not to do that thing (reportedly also for C99, not just for C++11)
 
4:38 AM
@RMartinhoFernandes If it's done only once in a base class, I'm okay with that. What about the derived class?
 
The derived class either gets a X& X::operator=(const X&), a X& X::operator=(X&), or none.
If you have struct no_rvalue_assign { no_rvalue_assign& operator=(no_rvalue_assign const&) & = default; void operator=(no_rvalue_assign const&) && = delete; }; I guess you make both of the implicit forms ill-formed for derived classes, no?
 
Don't think so. I'd expect the implicitly defined copy assignment operator to just call the &-qual one tbh.
 
There are no implicit operators with signature X& X::operator=(const X&) &.
@LucDanton Does that work? What if you call it on an rvalue?
 
@RMartinhoFernandes Inside operator=, *this is an lvalue no matter the qualifiers.
This is the only basis to my 'reasoning', and admittedly that's flimsy.
 
Well, but that still lets you call the assignment operator on rvalues of derived.
You need the operator on derived to have the ref-qualification.
 
4:42 AM
Yep.
 
So, boilerplate all the way down?
:(
 
I'd rather not delete the rvalue operator= and be done with that really.
 
Right, that's exactly what I was thinking.
I don't assign to rvalues anyway.
But it would be neat to be able to plug this hole in the language.
 
Does this sound reasonable?
 
4:50 AM
    template<>
    int CodecUtf8_< 16 >::do_length(
        state_type&                 state,
        extern_type const*          from,
        extern_type const*          from_end,
        size_t                      max_result
        ) const
    {
        typedef unsigned char UChar;

        (void) state;
        int nChars  = 0;
        while( from < from_end )
        {
            ++nChars;
            if( UChar( *from ) < 128 )
            {
                ++from;
            }
            else
 
here's a question
how do I know for sure if I'm being serially downvoted?
 
Stop scrolling Alf's code.
@DeadMG Ask @Als.
 
I have a nasty feeling on Programmers that some prick is most definitely downvoting me
but there's no way to actually know for sure
 
4:51 AM
@AlfPSteinbach What's (void) state; for?
 
warning suppression
 
Ah. I usually suppress the names for that.
 
also
I really, really hate the site's language restrictions
it's just unnatural
 
What restrictions? Programming or natural languages?
 
this site, the swearing restrictions
this guy is a fucking prick, that's how I'd say it, and how I'd like to express it
if he actually exists
my activity on Programmers is pretty limited
 
4:54 AM
lol
 
@AlfPSteinbach What's UChar?
I think there's a bug.
 
typedef'ed in the code shown as unsigned char
oh the parentheses are wrong
 
Oh well, maybe there's no bug, then. But compare UChar( *from ) < 128 from the if with UChar( *from < 128) in the while.
 
it didn't compile either
 
4:57 AM
Right, the last if has a misplaced closing parenthesis.
Why don't you stop early when you reach max_result?
 
i don't know, i haven't thought about optimization
        if( from_end - from > max_result ) { from_end = from + max_result; }
 
you come in peace, but I come in WAR
 
What's max_result for anyway?
 
@RMartinhoFernandes I don' t know. It's just required by the standard.
 
5:01 AM
i mean obviously it limits what the function can return
but i don't know the purpose of that
 
You could just pass a different end pointer.
 
no that line i posted would be wrong
premature optimization strikes again... :-)
 
your existence is wrong
;p
-2
Q: How to know if I'm a serial downvoter victim?

DeadMGI've got the nagging feeling, currently, on Programmers, that I'm the victim of a nasty serial downvoter who isn't being caught by the scripts because I have quite a low activity. And I certainly don't have the most moderate personality in the world, and could easily have posted something that so...

 
-2 already!
How's that a "feature request" btw?
 
I don't want to link downvotes to specific users. That's been (repeatedly) rejected. I want to link them to other, also anonymous, downvotes.
i.e., I'd like more information on who is downvoting me
 
5:04 AM
Oh there's is one.
Ignore my question.
Also, my meta name is still the human one.
Time to fix that.
 
argh
why my internets so slow?
it's 30MB/s cable and it's the middle of the night :(
maybe it's just the server
speedtest just ranked me at 31Mb/s so
 
Neat, I just found a way to cheat the "one change of screen name per 30 days" limit.
 
how
 
Go to another SE site, change it there, and copy to all profiles in the network.
 
lol
 
5:13 AM
The limit is per site, but the copy overrides it.
I'm sure there are enough sites to have a change per day.
I wonder if Welbog knows this.
 
g++ just ignores my utf8 facet. works fine with visual c++, where i don't need it.
 
nice
 
> I'll admit my bias. One Wednesday afternoon in May of 1977, when Star Wars opened in my home town, I saw, with my own two eyes, Han Solo take the first shot and kill Greedo. I know this. I witnessed it, so there is no doubt in my mind that it is so and I'll always know that is the truth.
lol
Damn, Science Fiction and Fantasy seems to foster TVTropes links.
 
5:33 AM
lol
 
Why is everyone so obsessed with Friday? we've had like 4 captions about Friday now.
Did something happen on friday?
 
I only counted 2.
@IntermediateHacker Yes, the work week ended.
 
no there are at least three.
 
Right, three. I only added the Wizard of Oz reference later.
 
5:41 AM
Well, Fred changed it to "Friday finally" or something on Friday. On Sunday I changed it to "It's not Friday anymore", because, well, it was Sunday.
 
You know, I'm getting a bit jealous of the D Programming Language.
if only it had an active community, it would be perfect.
 
I've discovered some nifty things about it.
I still don't like it for some reason.
Basically, I want some of its metaprogramming stuff on C++.
 
Me too. It has some things I really want in C++.
especially import instead of all the #includes
 
I really want to believe modules (that feature) are coming for the next revision, but I'm not completely sure.
 
it would simplify a lot of things.
but there are problems with D too. ( Java style interfaces.... )
 
5:52 AM
I just want the metaprogramming. static if is awesome.
 

« first day (388 days earlier)      last day (4561 days later) »