« first day (366 days earlier)      last day (4565 days later) » 

12:05 AM
Anyone online? I'm getting the impression I'm doing something silly here, and I probably need one of 1) help; 2) sleep; 3) coffee.
 
I'm here.
 
Good.
I have this traits has_f that tests if a type provides a certain optional feature in the form of a member function f.
And I'm writing a templated wrapper that holds a type and provides that same feature if the wrapped type does.
 
Any constraints on that f? Signature, presence of overloads?
 
No args, returns non-void.
 
obviously impossible for arbitrary functions, but for a specific f it should be relatively possible
inherit from a specialized base class, for example
 
12:11 AM
@RMartinhoFernandes What does the wrapper member f look like?
 
@LucDanton In this case it just delegates to the wrapped f().
If I write a member function, it compiles if I don't use that optional function. But the trait for wrapper<T> gives me true.
I can provide code, if you want.
 
Better make it a template for SFINAE.
 
I can work around this by moving this optional function into a templated base class, and specializing that.
@LucDanton What template parameters should I use?
 
Assuming T is the parameter of the wrapper then declare as template<typename U = T> decltype( std::declval<U&>().f() ) f();
 
Haha! I didn't think of defaulting.
 
12:15 AM
I've had issue with SFINAE and it took me some time to wrap my head around the concept.
But when whatever<T> is instantiated SFINAE won't work for its non-template members.
e.g. typename std::enable_if<some_trait<T>::value>::type foo(); will not be SFINAE'd out.
 
That's exactly the wall I was hitting.
Won't I have to call f as blah.f<>() though?
 
Nope.
 
@RMartinhoFernandes Example. This bind-like wrapper exposes cv-qualified overloads of operator() except some of those may not be valid in the first place.
Is this going be to look silly once I also take value category into account...
 
Parse failure.
 
12:21 AM
My operator() forwards to a wrapped operator() like you forward to f.
Except there's more than one.
Removed that silly mutable.
 
Do you know what that 3 next to the heart means?
The tooltip reads "followers", but the repo page only shows one follower (me).
 
Not sure, follower count is accurate for me.
 
12:36 AM
Even on the page that lists all repos?
 
Nope, it's different there.
I have two extra followers than I would otherwise except. Does this match your expectations?
 
Yes, it shows two more for all repos, except for the last one.
 
Also, how come every dormant repo got updated on 2011-09-08?
 
This is very weird.
 
1:13 AM
I'm sick :(
 
oh damn :(
 
I went and took some pills for my cold
great idea, it feels much better
pity my stomach decided to throw a revolt
this one might be an all-nighter
 
1:37 AM
You're always sick dude. You're sure there's nothing serious going on?
Fuck, I'm through with this crap. I'm going to buy a new router tomorrow.
 
uh, I'm pretty sure there is something serious going on
the problem is that my blood test never showed anything
 
I think that a lot of the more serious stuff like cancer almost always has strong signs in the blood
 
2:15 AM
@DeadMG my blood tests never show anything either
@DeadMG my stomach is wrong since 11 month's, and pills only make it better temporarily, don't worry ur fine, just eat more carefully :P
 
I wonder if std::array should have constructors taking a reference to array and a member that returns a reference to array.
As things are I have code that can accept an array rvalue but I can only store a reference to that array, which is obviously unsafe and silly.
At least in some cases.
(For comparison for any other rvalue that is passed a copy is stored.)
Well, fuck arrays.
7
 
2:45 AM
well, yeah.
lol
 
Right, but if std::array had those things I could handle them.
 
but could it have those things?
 
Admittedly the constructors would be weird as they would first default construct, then std::copy over the default constructed elements. Perhaps that's reason enough.
@FredOverflow Managed to make a type an aggregate, thanks for the help/rubber ducking :)
 
3:06 AM
Oh noes! I need to use mutable. I suppose it's a good idea to write everything else, see if it's const-correct, and leave the silent-writer function for last. Then everytime I make a change, comment the silent-writer, remove mutable, see if it's const-correct, restore. Are there any tricks to handle this easier, when only a single function mutates the state?
 
Better: why is that single function const?
 
Because it doesn't change any visible state and it makes sense to call it on const stuff.
 
I suppose your approach is doable but I usually have no qualms in marking mutable parts mutable leave it at that.
 
But, but, I'll never be sure!
 
Yeah, you're never sure with static analysis, or tests, or pretty much anything.
 
3:12 AM
(You mean, I'm being too paranoid?)
 
@RMartinhoFernandes Maybe your class is big enough that there is a risk that a logical const member mutates what it shouldn't. It's your call. I haven't found myself in that situation.
 
I guess that with C++11 we could have a [[ ns::silent_writer ]] attribute and have tools verify this.
Wait, better static analysis is one of the purposes of attributes, isn't it?
Or are they to add semantics?
 
I'm not sure.
 
Actually the SC was not very keen on attributes that change the semantics of the program, since it reduces (or downright removes) portability.
Considering one of the attributes is for marking functions that never return, I guess that falls into the realm of static analysis. Whether that's done by the compiler or a tool I don't think the SC cares either way.
 
3:19 AM
carries_dependency changes semantics, no?
Ah, no. It's just for optimization.
 
That's not to say that attributes can't be used for implementation-defined semantics, but I wouldn't say that's one of the core motivation.
 
Right, the only standard attribute that changes semantics is alignas, but it has special syntax itself.
 
Exactly!
Similarly final and friends were considered as attributes for a moment but that wasn't used.
 
It's weird that alignas is under attributes.
 
3:53 AM
hi guys need some help. i remember the standard recommending that arguments to main should be utf-8. but i cannot find that?
 
@AlfPSteinbach Not familiar with that.
Does that recommendation apply to the narrow encoding?
 
hello
can i be so bold as to ask a programming question in the lounge
 
@LucDanton it did but i cannot find it
 
Isn't that implementation-defined?
@JMRboosties You can. As usual, whether you get answer or not is not guaranteed.
 
lol ok
my question is java so that puts me in the doghouse even more im sure, its just that no one else is on and this question isnt worthy of an actual SO question: i have a URL object, and i want to extract the file only from it as a string
so www.website.com/directory/file.FS
i just want "file"
doing url.getFile() returns directory/file.FS
 
3:59 AM
6
Q: Get file name from URL

SietseIn Java, given a java.net.URL or a String in the form of http://www.example.com/some/path/to/a/file.xml , what is the easiest way to get the file name, minus the extension? So, in this example, I'm looking for something that returns "file". I can think of several ways to do this, but I'm lookin...

Should help.
I used "[java] url get file" as the search string.
 
thanks, i dunno why i didnt think to search for that
 
Hey does anyone know why you need a DFA (deterministic finite automaton) in order to complement?
 
^ because I find it hilarious that Windows 7 diagnoses default output of competitor compiler as a trojan
 
This is only true if A is a deterministic FSM. If A is nondeterministic, we must first convert it into an equivalent deterministic FSM, then take the complement. This can result in an exponential blowup of the number of states.
 
4:05 AM
@oorosco that's a stupid question. what does it mean?
 
i elaborated, sorry
I don't know why it has to be a deterministic
 
is the second thing a quote?
 
no ggood explanations on line. Thought cs people would know
yes.
 
@AlfPSteinbach Did that happen to you?
 
@RMartinhoFernandes yes, and to lots of others judging by googling the message
 
4:06 AM
What "part" of Windows did that?
That Windows Defender thing?
Or the monthly malicious software removal tool that comes with the updates?
 
@RMartinhoFernandes most probably. it doesn't identify itself
 
Ah.
@oorosco You're asking why you cannot take the complement of a non-deterministic FSM directly?
 
in the early 90's they had this message about PC-DOS or any other DOS than MS-DOS being unstable. the code to detect the DOS variant was obscured via xor. it was marketing ploy
 
@RMartinhoFernandes Yes. Basically, perhaps I'm misunderstanding what it means to take the complement of an FSM
 
I don't remember learning about the complement.
I can only assume it is an FSM that recognizes exactly everything the other one can't.
But I'm totally going on a limb here.
 
4:12 AM
hum okay. I've been trying to google the process of taking a complement of a FSM but no results. Trying to change up query now... <,<
no good* results
 
Some quick googling reveals I was correct in my guess, and to take the complement of a deterministic FSM, you just make every final state non-final, and every non-final state final.
@oorosco Do you know of NFA-ε?
I found a counterexample that shows why the same trick does not work for NFAs.
This NFA accepts the empty string.
 
4:27 AM
Yes i know nfa-e
 
If you make final states non-final, and non-final states final, it will make S₀ a final state.
This means that that transformed automaton will accept the empty string as well.
 
Which is bad why?
 
Because the complement of A must accept exactly what A doesn't accept. Nothing more, nothing less.
 
So basically because both accept E it's wrong?
 
4:31 AM
 
So taking a simple DFA
http://www.cs.dartmouth.edu/~cbk/8/10w/hws/PS-2/ec-dfa.png
That would result in having
b - 1 -> a
 
@AlfPSteinbach What are the leaves?
 
etc?
 
@oorosco Sorry, I don't understand your notation :(
 
from state to b to state a with input "1"
instea dof a to b with "0"
 
4:33 AM
Ah, no. To take the complement, you don't need to change the transitions.
You just make A and C final, and B non-final.
 
sbi
@RMartinhoFernandes How would he know? Do you think he cooks that?! He just copies this food porn off the Internet.
 
I see. I think I'm understanding this slightly better now
 
@sbi I don't know, that doesn't seem too hard to cook.
I'd probably screw it up completely, but it looks simple.
For now, I'm sticking with microwaves and fried eggs and such.
 
@RMartinhoFernandes I need to get better at googling for these types of questions <,<
Thanks for the help though :)
 
You're welcome.
 
5:04 AM
Arrgh. Heisenbug.
 
Just had one of those. I was mislinking to the wrong version of a library.
Getting better at fixing those things, I reflexively ldd now.
 
@RMartinhoFernandes basil
 
googles for "basil"
lol, some guy asked why his function was still returning negative values after he added an if to return 0. Negative values like 2.17691e-06.
 
Math is hard. Let's go shopping!
 
5:26 AM
So, I had this incredibly silly idea (as a joke) that if running the code under the debugger makes the bug go away, maybe one could just deploy the application with the debugger.
And the scary thing is...
4
Q: Reasons to NOT run a business-critical C# console application via the debugger?

DuffyI'm looking for a few talking points I could use to convince coworkers that it's NOT OK to run a 24/7 production application by simply opening Visual Studio and running the app in debug mode. What's different about running a compiled console application vs. running that same app in debug mode? ...

Someone actually implemented it.
 
5:46 AM
Does the debugger implement hot code swapping?
 
lol
 
That would enable super-fast server updates.
 
never underestimate the propensity of people to be total freaking idiots when there are no cattle prods around.
 
Too bad I don't have my C64 anymore :(
 
sbi
@RMartinhoFernandes Whether this is hard to cook or not relates to those pix in the same way the question whether it's easy to have a woman fall in love with you relates to porn. Look at those pictures, and then imagining spreading the sauce like that, with not a single drop off, and the olives all shining like they are freshly polished (the oil definitely slides off the olives on my plates), and the leaves arranged like that, without the top leaf being blown away by you breathing while taking the pic.
 
5:54 AM
@sbi damn it. now i got a foody.
 
I didn't mean to say that was a picture of something he cooked.
I meant he could have cooked something like it.
 
sbi
@RMartinhoFernandes Oh my Gosling!
 
Now and again I think it might be fun to take some old cartridge roms and reverse-engineer them to make high(er) level source code in some language that can produce identical binaries. It's a good thing too...because whenever that starts seeming like a good idea, I know it's time to put away the crack pipe.
This Prince of Persia fellow should take the hint as well.
This article on writing a 3GHz SNES emulator with perfect fidelity of the bugs also resonated with the "bad idea" part of how I think about spending time: arstechnica.com/gaming/news/2011/08/…
 
sbi
@RMartinhoFernandes Yeah, if course, frying a filet and adding some stuff to it shouldn't be too hard.
 
6:15 AM
@RMartinhoFernandes Where did you get that counter example? Because i'm having a similar problem understanding the closure for a Kleene star
 
I found a picture on wikipedia and realized it could work as a counter example. It wasn't designed to be one, I just used it that way.
 
Is there something good to read about plugin design and things like backward compability for plugins? I'm about to reread Drepper's "How to write shared libraries".
 
@RMartinhoFernandes Oh okay, dangit. I'm trying to figure out why Kleene star is defined a certain way but am clueless as to why. Are you familiar with the topic?
 
@sbi The fish (which is cod, by the way) is cooked by wrapping in aluminium foil and baking in oven. I haven't done it for cod, but I have done it for flat fish. It is a bit tricky, yes: the fish has a tendency to get stuck to the foil. I don't know how to get the perfect result shown.
 
@oorosco I remember a bit.
@AlfPSteinbach Photoshop!
 
6:25 AM
@RMartinhoFernandes s477.photobucket.com/albums/rr135/oorosco/… I am confused as to why there's an added state instead of s1 becoming a final state
 
Do you understand what the Kleene operator does?
 
Kleenex operator, hah, that was easyh
 
Yes. It creates all possible combinations of elements of the object it is attached to e.g. {1, 2}* = 11112221111, 1, 2, 12, 21, e, etc
 
but who would want to work as a kleenex operator?
 
@RMartinhoFernandes I'm confuused as to the example because it seems the added initial state that is also a final state is pointless.
 
6:30 AM
@oorosco Ok. Let me say it another way: given a set of strings it gives all possible strings made by concatenating zero or more strings from that set.
 
I miss democracy...
 
You understand that?
 
I understand what you wrote
 
The new initial state is also final to allow for the zero part.
The empty string is a member of S*, for every set S.
 
I understand..... [not]
 
6:31 AM
But if you made S1 the starting/end state wouldn't it accept the "E" anyways?
 
Let me see if I can cook up an example to show why you can't reuse the existing initial state.
 
Okay. Sorry that i'm ignorant haha. I just can't imagine an example where they wouldn't behave the same :/
 
This automaton recognizes all strings that start with zero or more alternating 1s and 2s, and end with 3. Like "12121212123". Right?
 
@oorosco i'm ignorant haha - that makes the two of us
 
so: (12)*U3
 
6:36 AM
I don't know what the U stands for.
 
union
 
How not?
 
(12)*U3 does not accept "123". It accepts "12" and "3", but not one followed by the other.
You want concatenation, not union.
 
6:38 AM
oh oops true that
anyways my bad haha
 
It's (12)*3.
 
Dammit my O level exams are just 5 months away
I can't program, I can't facebook, I can't hangout.
 
yep, i forgot about that
 
So, it only accepts strings that end with "3", right?
 
All I do is study. :(
 
6:39 AM
Yes.
O level?
 
Now, what happens if you make S0 final?
You can end before the "3".
"12" would be accepted, but shouldn't.
 
The O-level (Ordinary Level) is a subject-based qualification conferred as part of the General Certificate of Education (GCE). It was introduced as part of British educational reform in the 1950s alongside the more in-depth and academically rigorous Advanced Level in England, Wales and Northern Ireland A-level (Advanced Level). England, Wales and Northern Ireland replaced O-levels with GCSE exams in 1988. The Scottish equivalent was the O-grade (replaced, following a separate process, by the Standard Grade). Structure The O-level was predominantly exam-based. This was advantageous for st...
 
Oh okay, so what you're saying is that it basically messes with what is accepted in a way other than allowing it to accept "E"
 
Yes.
Because the existing start state can also be an intermediate state (as is this case). Making it final allows to end in the middle.
That's why you introduce a new state that does not conflict with what exists.
 
i KNEW that something like that happened but the way the example was depicted I didn't think of creating a loop like that, probably because the the "e" transition back.
thank you for pointing that that.
 
6:42 AM
... and they all listened in uncomprehending silence ~ Mark Twain
 
I wouldn't of realized that most likely.
lol. I read a part of it. But i really need to go to sleep. Thanks for the help like always @RMartinhoFernandes
 
Good night.
 
It's morning here...
 
Good night man, thanks again.
@IntermediateHacker Figures since i'm in the USA
 
@oorosco yeah.
bye
sorry for being a nuisance
Hey, in two months time I might actually go to Dubai!
Though just for one day. :(
About Skills Self-taught Open-Source Software Developer. Experience Unofficial: C++ : 1 Year Python : 1 Year , 7 months Official: None Profile Stackexchange I am mainly a hobbyist who likes to try his hand at every programming language there is. I mostly code in C and C++. I used to mostly code in Python, before I grew tired of its lousy performance, I still use it occasionally (like once a year). There is a long list of the programming languages I have tried my hand at, but some of the more well known ones are: C#, Pascal, Object-Pascal (Free-Pascal Standard), Lua, PHP, Java and Javasc...
Ok then. Sorry for bothering u guys and acting like a complete nitwit. Gotta go study now [ :( ] . Bye.
 
sbi
7:10 AM
@AlfPSteinbach Ah, that sound a reasonable method of preparing fish filets. Wouldn't oiling the foil help against sticking? No, maybe not, I guess it's the heat that makes it stick to it. Well, I guess I will have to try this method.
 
> The source of the problem on the Yorktown was that bad data was fed into an application running on one of the 16 computers on the LAN. The data contained a zero where it shouldn't have, and when the software attempted to divide by zero, a buffer overrun occurred -- crashing the entire network and causing the ship to lose control of its propulsion system.
This must have been hilarious.
 
7:28 AM
i'd figure code in a system where launchMissiles() could actually exist, would be tested a bit more thoroughly...lol
 
They decided to run Windows NT.
 
like, NT4?
lol
 
ah...ok
 
8:03 AM
@RMartinhoFernandes Your list sounds like a programmer's survival kit :)
 
Ernie is impeded by that duck.
 
@DeadMG What about a stool test? Problems with your digestive tract can often be identified that way.
 
cpx
is there a rule on reading complex types called "right to left" ?
 
@LucDanton You can easily write those as free functions.
 
@cpx first i've heard of it
 
8:12 AM
@cpx Yes, but I prefer the real way ("real" as in "how the compiler does it"). Simply apply the syntax rules :)
 
@FredOverflow Not the second one. (std::array -> array)
 
the only useful right-to-left rules i've ever dealt with involved operator associativity and calling conventions
 
@cpx A more accurate description would be 'from the inside out'. But that gets involved fairly quickly.
 
@RMartinhoFernandes interesting -- all the links are dead
 
so what is this rule about complex types?
 
8:18 AM
@cHao Start with the variable/typedef name. Look to the right: if it's followed by [N], it's an array of N elements; if it's followed by (arg0, ..., argN) then it's a function type; otherwise it's plain. Then look to the left: if there's a type, that's the element type, or return type, or plain type respectively. If there's a * or &, it's a pointer or reference; then you need to step out to get the type that is referred to. (continued)
 
If there's T::* then it's a pointer to member of T; then you need to step out to get the type of that member.
 
cpx
is this good?
 
So as you can see 'from the inside out' isn't really descriptive of the whole process. Plus, when there's no actual variable/typedef name, it takes some getting used to.
 
cpx
@FredOverflow how the compiler does it?
 
8:20 AM
Try to apply my algorithm to void* foo[42] and void (*foo)[42] and see if that helps.
 
@HostileFork stole that for fb
 
"killed to death"...lol
 
One of the worst ways to die.
(Reddit title.)
 
@LucDanton Want me to prove you wrong? ;)
template<typename T, size_t N>
T(&gimme_the_raw_array(std::array<T, N>& arr))[N]
{
    return reinterpret_cast<T(&)[N]>(arr.front());
}
@cpx The compiler blindly follows syntax rules.
 
8:23 AM
@FredOverflow There's no guarantee that works.
 
@LucDanton why?
 
@AlfPSteinbach Sesame street is simply surreal these days. Perhaps moreso as it was just hacked on YouTube and substituted with porn. But I can't get over the Michael Bolton and Lonely Island song, I'm still cracking up over it. Most I've laughed in like, a year.
 
@FredOverflow Implementation are allowed to use black magicks to implement std::array.
And the cast is implementation-defined behaviour. Maybe not.
 
But front() must give you raw access to the first element.
Also, I don't believe it can use black magic, because std::array is a POD/aggregate/whatever the correct term is.
 
Let me check the wording but IIRC what's specified is that 'aggregate initialization works'.
 
8:26 AM
Otherwise, you would have serious C incompatibility problems (and the brace initialization probably wouldn't work).
 
An array is an aggregate (8.5.1) that can be initialized with the syntax
Obviously there's the contiguity requirement for C compatibility but that doesn't mandate using T[N] as a backing member.
So for instance an implementation could decide to use T[N + 1] as a backing member. I don't see that conflicting with any of the requirement, and that's not even black magicks.
 
@LucDanton And would that make the reference cast undefined?
on a different note:
0
Q: constant arrays

FredOverflowThis is a good old C array: int a[10]; And this is a good old C array that is const: const int b[10]; In C++, there seem to be two ways to define std::arrays that are const: std::array<const int, 10> c; const std::array<int, 10> d; Are these two definitions equivalent? If so,...

 
@FredOverflow Implementation defined I think.
 
@LucDanton Anyway, why do you even need these two functions?
 
@FredOverflow It's not so much that I need it that having those would remove a corner case.
I have a neat forwarding bind helper (well, bind-like), except it can't forward arrays.
 
8:37 AM
> T elems[N]; // exposition only
> The member variable elems is shown for exposition only, to emphasize that array is a class aggregate. The name elems is not part of array's interface.
It seems that only the name is "unspecified", but the size is not?
 
Exposition = non-normative. It means the std::array shall behave as if there was such a member.
Although yes, I assumed there was no requirement on size. Don't know if that exposition means there is or not.
 
That implies to me that the reference cast should be well-defined, because it should work on the elems array as defined above. Otherwise, that would break the as if rule, wouldn't it?
 
I'm skeptical.
 
skeptical or pessimistic? ;)
 
I wouldn't say pessimistic; I have nothing to hope for here.
Implementation-defined behaviour is not good enough for me here.
 
8:42 AM
:)
 
Casting from first member to underlying array is simply not something I do.
 
I don't think there is a cleaner non-intrusive solution.
 
That doesn't make it clean in the first place :)
 
Hm, if std::array only has that one member, how about the following, slightly shorter abomination? ;)
template<typename T, size_t N>
T(&gimme_the_raw_array(std::array<T, N>& arr))[N]
{
    return reinterpret_cast<T(&)[N]>(arr);
}
 
I forget what guarantee we need to make the cast better than implementation defined. (Disregarding the concern regarding the size.)
Not standard layout, that's too restrictive. The same one but not recursive?
 
8:46 AM
What version of the C++ standard ships with <array> ?
 
TR1 and C++11
That is, Visual Studio 2008 SP1 already has it, albeit as std::tr1::array if I'm not mistaken.
Visual Studio 2010 has is as std::array.
 
Seen boost::array before, somewhere, I think.
 
> An object pointer can be explicitly converted to an object pointer of a different type.70 When a prvalue v of type “pointer to T1” is converted to the type “pointer to cv T2”, the result is static_cast<cv T2*>(static_cast<cv void*>(v)) if both T1 and T2 are standard-layout types (3.9) and the alignment requirements of T2 are no stricter than those of T1, or if either type is void.
Text for reinterpret cast.
> Scalar types, standard-layout class types (Clause 9), arrays of such types and cv-qualified versions of these types (3.9.3) are collectively called standard-layout types.
So you're screwed anyway for arrays of non standard layout element type.
They don't call it array decay for nothing!
 
amagad trains no worky!
 

« first day (366 days earlier)      last day (4565 days later) »