« first day (851 days earlier)      last day (4099 days later) » 

user142019
8:00 AM
Meh SQL.
 
user142019
What a bad language.
 
user142019
-1
Q: C++ code performance is low

Black_HorsePlease have a look at the following code #include <iostream> using namespace std; int main() { int n = 0; int k = 0; int t = 0; int count=0; cin >> n >> k; for(int i=0;i<n;i++) { cin >> t; if(t%k==0) { ...

 
user142019
Downvote, close and delete.
 
Found the courage to go check the Standard proposals. std::optional<T&> has been removed from the current proposal and will be submitted separately. So far so good!
get_value_or is still too stunted to my taste.
 
8:22 AM
3
Q: When not to use `auto&&`?

balki auto&& mytup = std::make_tuple(9,1,"hello"); std::get<0>(mytup) = 42; cout << std::get<0>(mytup) << endl; Is there a copy/move involved (without RVO) when returning from make_tuple? Is it causing undefined behavior? I can both read write the universal re...

Am I being stupid or is it true that auto&& can be used everywhere?
 
user142019
@Pubby IT'S UNIVERSAL!
 
(and by everywhere I mean the form auto&& x = fun(); )
 
@Pubby Yes.
 
If I have a template function template<typename T, size_t N, size_t M> void stuff(const T(&)[N][M]), is there a way to access the elements or is that not possible?
 
Not without a name.
 
8:28 AM
Yeah I tried that too
 
@Rapptz It didn't work?
 
Nope
 
You borked something.
 
Well it tells me..
note: couldn't deduce template parameter 'N'
 
You are not passing something of the proper type.
Did you let your array decay?
 
8:32 AM
yeah it seems like it's decaying to a pointer :/
i.e. printBoard(const T (*)[M])
 
user142019
Hmm.
 
No dice then.
 
user142019
Haskell as a language for database queries. :|
 
@R.MartinhoFernandes I don't understand the closing (it's not my greatest morning).
 
What closing?
 
8:33 AM
@Zoidberg IIRC haskell has a database library thing
 
Oh, that question?
 
Question from earlier.
 
I was asleep. It's not my greatest morning.
I have a reopen vote in already.
It's sad how fast it got closed after that...
I make a mistake, and four people quickly repeat it.
 
I would jump off a cliff too if the robot did it
2
 
lol
 
8:36 AM
The funny (and sad) thing is that there is a part of me that just doesn't want to know the answer. I wonder if there's still hope C++11 will be just forgotten at a faster pace than it's adopted... — 6502 15 mins ago
WTF, two votes.
Oh wait, that's the dude that thinks const should not exist.
 
Isn't there a question about the difference between auto&& and auto already? I need to reference it (unless I'm imagining it).
0
Q: Automatic type deduction and auto&& vs auto

ronagI just watched Scott Meyers Universal References in C++11 and there was one thing I could not quite understand. I am a bit confused as to what the difference is between a auto as a "universal reference", i.e. auto&& and a regular auto, when do they differ? Foo f; Foo& lvr = f; auto...

Sucks.
 
I.. split it into two functions instead and I got it to work.
Whatever works I guess.
 
Is there a pro-tip for finding a past discussion between two members in the chat?
 
@Pubby I find that incredibly annoying. I have seen it happen ever since I have been to school. I have recently seen it happen in German class too. I don't like it when people stop thinking like that. It makes for a sad robot.
 
user142019
Lonely boxman?
 
8:46 AM
@R.MartinhoFernandes But what if the cliff was on fire?
 
@LucDanton 1) Try searching for something (it does not really matter what, you can achieve step #2 with anything); 2) bitch about how much chat search sucks; 3) no profit.
 
Xeo
Mornin'
 
@R.MartinhoFernandes stop listening to what other people say and then they will do the same!
 
@R.MartinhoFernandes Of course I found it moments after asking. I guess your advice is great then? Complain, then find?
 
@R.MartinhoFernandes If you don't like it we don't like it either.
 
user142019
8:48 AM
Eww date and time in separate fields.
 
-19
Q: 代写论文|代写留学生作业|how to implement a program to total lock Windows 7 OS using .NET

uniguyit1our company have a program task, need to develop a program using .NET or C++, this program's objective: when run it , windows 7 will be totally locked, can't do anything , except you input a password. how to implement, give me some code or important hint ,thanks ver much! 代写论文|代写留学生作业|代写essay代...

^^ lol
 
user142019
-1 but I didn't even read it.
 
-14
Q: True or false: please answer the following 10 and win a big prize?

Joanna SarahTrue or false: A class provides a description of the layout of data values? A class provides a description of how object actions are performed? A class provides a description of how object actions are available? Each object has its own copy of instance variables defined in the corresponding c...

^^ lot of good stuff today...
 
user142019
idem
 
user142019
@Mysticial LOL
 
8:52 AM
I just did what I will call a half-a-character edit.
@Mysticial I like the irony of the single answer.
 
Two answers and I went to the Standard discussion groups. Today is a weird day!
I'd claim it's the ideal day to start writing a range library but I have yet to fix my range from yesterday so.
 
I should probably find something to answer on SO.
Been more than a month since I've posted anything.
I've been more active on meta and Anime than here... :(
 
@R.MartinhoFernandes Btw is there an easier way to fix that than an explicit spec? Brain says no, but I don't trust it right now.
 
Xeo
@Mysticial I can relate.
 
@Mysticial I don't see the problem! (Assuming here means SO proper and not the chat of course.)
 
9:02 AM
I mean, I have my auto-refresher on much of the time. (set to 30 seconds)
But there hasn't been anything worth answering lately...
 
¬_¬ how many 'values' are there in C++, I know there is r and l... but isn't x also one?
oh, and morning all :D
 
Xeo
prvalue, lvalue, xvalue
 
user142019
lvalue, rvalue, glvalue, xvalue and prvalue.
 
glvalue and rvalue subsume the three.
 
Xeo
and then generalized categories rvalue(xvalue, prvalue) and glvalue(xvalue, lvalue)
 
user142019
9:03 AM
But I have no idea what glvalue and prvalue are. xD
 
Man, 'subsume' is an awesome word! I need to keep using it.
 
Xeo
@Zoidberg old lvalues and rvalues
kinda
 
user142019
Ah. :P
 
¬_¬ so there is sort of five.. but really three?
 
No. Dogs and cats are all mammals.
 
9:04 AM
@LucDanton Yeah SO proper. I've really done nothing other than post comments for the past month.
 
Good for you.
 
:(
 
@LucDanton yes, but species are not (I think that group word is this) domain (could be genus perhaps...)
 
@LucDanton Ha, you mean, you are starting to wonder if you should drop explicit constraints on every single function you write?
 
@R.MartinhoFernandes No.
 
9:06 AM
Then I don't get the question.
 
@thecoshman Right, I don't think it's wrong to think of the top of the hierarchy (i.e. glvalues and rvalues) as being different in kind than the other three.
No need for paradoxes :p
@R.MartinhoFernandes I can fix my optional but the only fix I know is tedious to implement. Is there an alternative?
 
For it to not be copy constructible on unique_ptr?
(In all honesty, I have faced this question before and just SEPed it away until now)
 
Yes.
 
And I really wish you hadn't asked. I don't want to think about it :(
 
@R.MartinhoFernandes not enough templates for you?
 
9:12 AM
@R.MartinhoFernandes SEPed?
 
Somebody Else's Problem (also known as Someone Else's Problem or SEP) is a condition where individuals/populations of individuals choose to dissociate themselves from an issue that may be in critical need of recognition. Such issues may be of large concern to the population as a whole but can easily be a choice of ignorance at an individualistic level. Author Douglas Adams' description of the condition, which he ascribes to a physical "SEP field," has helped make it a generally recognized phenomenon. Somebody Else's Problem used to capture public attention on matters that may have been over...
 
ah
 
Well hopefully I get my thinking in order and I can be done with concat_map and I'll be your somebody else.
 
user142019
lolwat
 
well, I'm not sure why you even would use an optional<unique_ptr<T>> anyways
why not just use unique_ptr<T> directly? it already has an empty state.
 
9:13 AM
Basically, something I know is a problem, but also know is complicated enough that I don't want to be the one solving.
 
std::unique_ptr<T> is my go-to move-only archetype. You're reading too much into it, you dolt!
 
@DeadMG Point is optional<moveonly> is copyable, according to the traits.
 
oic
 
@R.MartinhoFernandes like cake
 
@LucDanton Oh, you're still working on concat_map? Awesome.
 
9:16 AM
Debugging stage, really. I stuffed all the state in yesterday, the logic isn't plumbed just right apparently.
 
The C# compiler does the transformation automatically. I have been wondering how easy it would be to do in C++. The scary bit is that I keep coming back to thinking of continuations.
But then I realised RAII = try-finally.
 
@R.MartinhoFernandes That was how I was going to implement destructors.
and I suggested a long time ago that RAII was try-finally, but somebody bit my face off :(
 
(To be clear, I mean from a semantics point-of-view, not from a usage point-of-view). I mean that I can transform all instances of RAII into try-finally and then use the same transformation mechanism as C#.
@DeadMG Isn't that what rabid dogs do?
 
what are you lowering into?
 
@DeadMG Iterators.
 
9:21 AM
oic
 
The only obstacle left is transforming from iterator-that-knows-the-end into piece-of-shit-needs-separate-iterators.
That can be done easily by sticking that ugly boolean is_end_iterator.
But what of ownership?
 
@R.MartinhoFernandes That was back in, say, 2009 right?
 
eep
 
If I have a single piece, I can have it own all the state.
If I have two pieces, ...
@LucDanton Yeah, I meant "I realised RAII = try-finally would help."
 
You can write a range type that has the state and input iterators that defer everything to that range :/
 
9:23 AM
@LucDanton And share ownership of that range object?
 
Typical use of ranges is foo(Range cvref r) { /* use begin(r) and end(r), perhaps indirectly */ }. I haven't yet thought of a lifetime issue.
Big caveat: As long as you compose further ranges from the range itself. If you make a new range out of the begin(r) and end(r) pair and compose that then yeah, it gets iffy.
 
It's not an entirely new consideration, what with iterator invalidation rules. Even if you keep an std::vector<T> alive, you have to think about that.
@R.MartinhoFernandes Isn't the point of a range library to abstract over iterator pairs?
 
And speaking of, we might need to lay our expectations of a range library on the table actually.
 
9:28 AM
But it has to get rid of them everywhere except on the interop boundaries.
@LucDanton The main things I'm concerned with are composability and deferred evaluation.
Without that I can just materialise everything into vectors and use vectors as my "range primitive".
 
I don't know what to expect or require of the range concepts. How they should relate to the iterator concepts (which ones?). Which is directly connected to compatibility with the Standard algorithms.
@R.MartinhoFernandes I'm already playing with fire here and I have yet to burn myself.
I.e. for(auto&& e: zip(a, b, c)) just 'works'.
(I'm sure you're aware, but you've seen me play with 'perfect storing' and the like before. I've done that with ranges, too.)
 
Yeah. But in writing docs for ogonek, I have wondered about some non-evil patterns where ownership fucks shit up.
Dammit, silly typo changed the meaning of my sentence.
 
I'm interested if you can find a condensed example actually. (I'm okay if you don't have the will/time just right now though.)
 
I should have noted them down though. :(
I admit I am not entirely sure if these are just unreasonable expectations of behaviour stemming from my experience with C#.
 
Xeo
0
Q: Assign vector to multiset

user1873947Is there any good way for assigning std::vector to std::multiset? Other than iteration of course. I see that in C++11 there is something like initializer list, maybe it can be used somehow?

 
9:34 AM
It's just something that has been gnawing at the back of my head but I haven't taken the time to pay enough attention to it to realise the core issues.
 
Xeo
sigh
 
The big thing I'm relying on so far is that the two big consumer of ranges is range-for, which is auto&& r = expr; auto b = begin(r); /* so on */, and the Standard algorithms, which I'm pretty sure are boost::algo(Range cvref r) { return std::algo(begin(r), end(r), /* so on */); }. So they really look alike.
 
Xeo
@Xeo They are uncomfortable and probably it's not the fastest solution. — user1873947 10 secs ago
Throw. The. ROOOOOCKS CHEEEEESE!
 
mawning
oh no, you guys are talking C++.
 
@LucDanton Yeah, that's why I haven't invested the time to explore this fully yet: the main usage patterns are just fine.
Btw, have you been following the ranges mailing list?
I have lost interest once it started being all about the algorithms that should be in. I haven't seen discussion about "fuck iterators, we don't want that shit".
 
9:37 AM
@R.MartinhoFernandes Can I assume you wouldn't be satisfied with storing all the state in one object, using a null object as end iterator, and putting the two inside a variant<smart, dumb> (because range_iterator<R>::type it = /* stuff */; still has to compile)? I.e. going algebraic?
@R.MartinhoFernandes Ah, you're already being thorough! I'm not sure where to start, myself.
@R.MartinhoFernandes No.
 
@LucDanton Why not? FWIW, I was considering this for automating the process (isn't libclang meant to be all about fostering an environment of neat code manipulation tools?)
So uglies underneath are not that problematic, as long as they are not semantic uglies.
 
Because it wasn't suggested already! Since a range-for is so simple it's something that I've been eyeing for a while. (I.e. for that case there won't even be a sum!)
 
In fact, since I was planning to steal the C#'s compiler algorithm as a basis (I have (un)fortunately grown acquainted with it by looking at generated code through a decompiler without the smarts for yield return), there will be uglies.
 
@R.MartinhoFernandes Sorry but I don't follow why you mentioned libclang.
 
9:42 AM
@LucDanton The plan was to write code similar to what you write with boost.coro and have a tool produce the iterators for ya.
 
Well, good thing we're laying out our expectations down on the table lol.
 
> The C# compiler does the transformation automatically. I have been wondering how easy it would be to do in C++.
I thought this was clear enough :(
 
Well I wonder about things myself, too. I'm not set on implementing them all though.
 
@TonyTheLion o_o
 
9:47 AM
Doing it by hand is painful.
 
so it's Valentine tomorrow
 
Ell
I'm glad I don't have a date
 
I guess I'll buy myself a box of chocolates and some flowers :P
 
Ell
Girls cost too much to maintain
 
ahahahah
 
9:47 AM
Sigh.
@Ell I won't draw the obvious conclusions for you.
 
Ell
Haha
 
0
Q: incorrect epoch unix time value for larger year (2048)

Gopali need to get the epoch time for the date and time enter, but when i enter like 2048(year), i am getting very large value, "18446744073709551615", which is supposed to be incorrect.. when i enter the date like 2012(year), 2015(year), it epoch value is correct, any changes i need to do for the 20...

hahahahaha
 
@R.MartinhoFernandes Btw what's your opinion of Boost.Iterator, and its refinements of iterator concepts?
 
10:06 AM
@LucDanton I like the separation of traversal and access concepts.
 
k. I ain't even mad the proposal might not make it in the Standard as-is (IIRC it already had an impact for C++11 though), because the CRTP helpers are just so goddamn useful.
 
hopefully, we won't need to refine iterator concepts because we have ranges
 
@DeadMG Have you been following the range mailing list?
 
um, what should the result of a concat_map do when seen through const?
 
not that much
why?
 
10:10 AM
@DeadMG I don't find the discussion there very uplifting.
Last I checked people were more concerned with replacing <algorithm> or something.
@LucDanton I don't understand the question. What should it be when seen through non-const?
 
I see wat u mean thar
 
A range over the flattened results of calling f yadda yadda.
 
And the same thing through const?
 
Whoa Nellie.
You want mutable Functor functor;?
Or you want me to duplicate the work?
 
Oh.
That's messy.
 
10:13 AM
Yup.
 
so basically
the Standard ranges mailing seems to have gone off on a complete tangent
and nobody seems to have a clue about actual ranges.
 
My 'ideal' approach would be that not all ranges make sense when seen const, esp. those that are the results of composing (well, technically, that close over some ranges and/or additional values). The 'problem' though is that due to lack of perfect forwarding a lot of C++03 code goes Range& + Range const& overload. Then guess what happens if I do foo(concat_map(blarg, glux))?
 
@DeadMG Haven't checked much lately, but at least that's how I saw it at the beginning.
 
And yes, writing my own annex::algo(Range&& range) { return std::algo(begin(range), end(range)); } is looking more and more appealing.
 
@R.MartinhoFernandes The last few issues are all about PTMFs.
 
10:16 AM
Wow.
Hmm. What.
lol
 
Anyway, I want to pass my unit test that only uses range-for so far first and foremost, so I'll forget about const.
 
@DeadMG That's a pretty strong non sequitur.
Btw, found a neat pic relating the three operators we discussed yesterday /cc @Xeo
 
@R.MartinhoFernandes Wat?
 
@R.MartinhoFernandes That's fun.
 
@DeadMG Non sequitur: an irrelevant, often humorous comment to a preceding topic or statement.
The sad part is that I don't think you intended it in humour.
 
10:20 AM
it would be funny if it weren't true
but unfortunately, it's a plain statement of fact about how off-topic they are.
 
Xeo
@R.MartinhoFernandes And a "monad" is still a shroud of mystery. :) I'll just think of monads as wrappers.
 
@Xeo The monad in question yesterday was "range". You don't need to know what it is to understand those operators in context.
 
Xeo
Yeah
 
@Xeo You're dumb. It's obviously a cloud of mystery!
 
Xeo
lol
 
10:21 AM
@Xeo That said, if you understood it yesterday, you already understand monads. You just haven't realised it.
 
Xeo
Btw, if I want to write some program in Haskell, what do I need besides GHC?
 
For some values of 'need', the Haskell platform.
 
Xeo
k
 
@LucDanton I was just about to say
 
10:22 AM
Yeah, just install the Haskell platform directly.
 
I remember trying to install some program written in Haskell and there was all sorts of horrible shitting around going on until I gave up
 
What does 'install' mean here? Binary? Build from source with automatic fetching of dependencies?
 
Xeo
Awright
 
@Xeo Btw, the unit/return operation of a monad is just a less generic form of ana. So you already understand a concept more powerful than monads.
 
@R.MartinhoFernandes Btw I'm frustrated enough that I'm writing all my class members inline.
 
10:24 AM
@LucDanton hahahaha
 
@LucDanton Dunno, the robot told me wtf to do.
@LucDanton Happens to me often.
 
Everything's public too! But in a detail namespace, so don't peek.
 
tbh
I think that we should simply add access specifiers to namespaces.
 
Xeo
@LucDanton Uuuh... ain't that normal for templates? Or do you normally define them out of class?
 
@DeadMG No, you want modules, remember? Namespaces are cross-TU.
 
10:25 AM
Since I already write members inline, when I'm frustrated I skip the detail namespaces.
 
@Xeo Latter.
 
@LucDanton Oh yeah.
de-inlining class methods is one of the passes I do after hacking something together to clean it up/
 
(Not that private detail namespaces is a nonsensical idea, but that would be something new to consider.)
 
What if your dog bought the app too?
 
10:28 AM
Anyway as a complete Haskell newbie I followed this to write my first real program. Invoking GHC was becoming annoying. (A more accurate name for that tutorial would be 'how to set up a dev environment for Haskell' though.)
lol
wtf, first time I see an edit do that.
 
IOW, first time you fuck up like that.
 
Xeo
Always interesting when people learn that unordered_stuff::reserve doesn't do what they think it does: stackoverflow.com/q/14851249/500104
 
bool equal(range_iterator const& other) const
{ range == other.range && !range->empty(); }
Who needs bool is_end_iterator;?
 
@LucDanton You just hid it inside the optional, you cheating bastard.
 
No, that's a pointer. I'm trying lifting everything inside the range object.
 
10:35 AM
IOW, I don't care, I still think in terms of algebraic types most of the time.
 
I'm renaming that single_pass_range_iterator. Should be straightforward.
 
0
A: What's the difference between the rehash() and reserve() methods of the C++ unordered_map?

tugay ilbayFrom cplusplus.com: rehash: A rehash is the reconstruction of the hash table: All the elements in the > container are rearranged according to their hash value into the new set of buckets. This > may alter the order of the elements within the container. reserve: Sets the number...

eek cplusplus.com
 
@LucDanton Maybe change the order for efficiency?
 
Xeo
@R.MartinhoFernandes If range is a pointer...
 
@R.MartinhoFernandes Oh yeah.
 
Xeo
10:37 AM
I don't think that makes much difference?
 
Also there's no return lol.
 
Xeo
lawl
 
@R.MartinhoFernandes I could even stick to !range->empty(). Won't for now.
 
Btw, have you started to hate equal() above all else already?
 
10:39 AM
Oh boy I think I'm going to like the implementation of end(). Who wants to take a guess?
@R.MartinhoFernandes No.
The mess of putting the state where I can find it is just too overwhelming.
 
Xeo
@LucDanton return nullptr;? No wait, you'd need to check that everywhere...
 
Ye.
 
@Xeo return { nullptr };!
 
Xeo
lol
 
Converting constructor either way :/
 
Xeo
10:44 AM
@LucDanton Wait, so just range == other.range && !range->empty(); doesn't cut it - what if you compare two end iterators?
I'm lightly confuzzled.
 
I think that's a good point. But I'm focusing on the range right now since that's supposed to have the actual functionality.
 
@Xeo Hahaha. equal() is always confusing. There's a reason I tend to fallback on is_end && other.is_end || underlying == other.underlying.
 
Xeo
Single iterators would be so nice~ Although those would effectively be ranges, wouldn't they?
 
Yes.
Maybe we should name 'a range library' any half-baked attempt like Boost.Range, and 'a cursor library' the more ambitious stuff (with new concepts).
This hit me because right now I'm storing a Range and an Iterator -- because that's the Boost.Range kind of range (and I want to support rvalues).
 
Oh, btw, I have an old half-assed attempt at implementing Andrei's range concepts here bitbucket.org/martinhofernandes/rtl
 
10:52 AM
I forgot about that.
 
Don't assume anything there is worth it. I had almost forgotten about it too.
Apparently this is op== for the interop iterators: return (!r || r->empty()) && (!rhs.r || rhs.r->empty());
 
Fascinating. Is the nullptr case for e.g. default construction?
 
Yes.
r is an optional<Range>
It sucks, btw.
 
I'm confuzzled. An iterator gets its own copy, separate from that of an end iterator?
 
It only ever compares true on the end.
@LucDanton And end iterator gets nothing.
 
10:56 AM
lol I get it.
 
I noticed there are lots of questions where the response is 'what were you expecting?' I wonder whether something like ideone.com but with expectations would be useful. E.g. running this code with this input I was expecting this output. I'd love to do it but know I probably won't so thought I'd share the idea.
 
It is not meant to allow partioning [begin, end) as in the STL.
It supports ranged-for, basically.
 
Don't put it like that. Say 'the iterators are a model of InputIterator'. Because a == b not implying ++a == ++b is a feature :p
 
Well, yeah, I guess that works too.
 
(I've planned that retort since the beginning.)
 
10:58 AM
I should have documented the decisions I made back then.
 

« first day (851 days earlier)      last day (4099 days later) »