« first day (2171 days earlier)      last day (2770 days later) » 

Ven
11:00 AM
You just want to disable specialization
 
You just want to see the world burn
 
user1804599
@Xeo The body of the function would have to be restricted to the concept.
 
user1804599
@Xeo In Rust, type parameters have an implicit Sized constraint. You can disable it with where T: ?Sized.
 
user1804599
When you work with a type that has no Sized impl, then you can't move it.
 
user image
4
 
Ell
11:06 AM
@Ven that wouldn't do
 
lol
 
user1804599
@Ven And type traits.
 
user1804599
And sizeof on type parameters.
 
user1804599
Etc.
 
user1804599
But yeah you probably want some implicit constraints like in Rust.
 
user1804599
11:07 AM
You basically just want C++ to be Rust, that would solve all problems.
 
Ell
nah
 
user1804599
Blit-move/copy is a killer feature.
 
Ven
Lol blitting
 
Blit?
Isn't that a bad word?
 
Ell
wat
 
Ven
11:16 AM
???
 
nwp
Why can I not just use latex without learning to use it?
That's like people having to learn programming before they can write their program, what a dumb system.
 
user1804599
Because it's a good tool, and good tools require practice.
 
Mankind's most ancient question
 
Ell
@ChemiCalChems oh geez
that voice
so high
terrible
 
11:23 AM
yeah
it's hard to appreciate the NN's output when the NN's input sounds so fuckin' terrible
 
@Puppy people were requesting morgan freemans voice to be learned
that would be nice
 
Ell
@Puppy yep
 
nwp
latex rendering a link -.-
 
@Puppy ikr
@ChemiCalChems Basically I AM SO ANNOYING LOOK AT ME I'M SO CUTE AND NOW I'M A CUTE ANNOYING MACHINE! :3 AHHHH-HOHO-HEEEHEEEEEEE-kuhhhhh-AHOHAHEHOHIHA
 
@VermillionAzure when it learns the "sh" sound
sh aa shhh hshhshshhshsh h eee ssh hsshsshh
fucking hell
 
11:30 AM
@ChemiCalChems ikr
 
> Google's self-driving car is the victim in a serious crash
 
Who is this guy anyways?
 
Finally, a true incident. Let the FUD begin!
2 messages moved from C++ Questions and Answers
> Google's self-driving cars don't have a flawless safety record, but it's clearer than ever that careless human drivers remain the greater threat. A commercial van running a red light struck one of Google's autonomous Lexus SUVs as it crossed a Mountain View intersection, seriously damaging the side of the vehicle. Neither the Google observers nor the van driver were hurt, thankfully.
However, this is likely the worst incident to date for Google's driverless cars -- previous crashes have typically involved humans rear-ending the robotic cars at low speed.
 
user1804599
muon_value *muon_int(intmax_t value) {
    muon_value_int *result = GC_malloc(sizeof(muon_value_int));
    result->base.layout = &muon_layout_int;
    result->value = value;
    return (muon_value *)result;
}
 
user1804599
 
11:32 AM
@VermillionAzure please, don't copy that ad-hominem "other-people" attitude from certain other rooms
 
@sehe Oh no I'm talking about the guy who made the video
Not him lol
 
Oh. That was confusing. Sorry.
 
Not trying to be "this guy ~~~" not me
 
@набиячлэвэли the best part of these videos for me is that the guy is speaking spanish but i can't understand him anyway
 
11:43 AM
@набиячлэвэли that laugh though
 
raaaaaaaaaah!!!!!!
writing exception safe containers is hell
every fucking thing can throw
 
@orlp lol exception safe
@orlp What do you mean by this?
 
@VermillionAzure well, let's say you're reallocating your vector
because you've ran out of space
but suddenly a move constructor decides to throw while you were moving to the new location
what do you do now?
move back the elements?
 
user1804599
haha exceptions
 
but what if that throws?
 
11:50 AM
@orlp But the memory allocation succeeded right?
 
@VermillionAzure who the fuck knows
that can throw too
 
user1804599
require noexcept
 
@orlp So... what type of safety are you going for?
Strong or basic?
 
strong
whatever the standard requires
and at no point should I leak memory
 
Xeo
@orlp You don't move unless you have nothrow move ctors
You copy instead.
 
11:51 AM
@Xeo I know
I was just simplifying the issue
detail::make_move_if_noexcept_iterator
=/
 
> This means that the implementation can call no operations on T except to destruct it or move assign it. Note that if the implementation move assigns T that doesn't guarantee that a move assignment operator will be called. For example T may not have a move assignment operator, and so in that case a copy assignment operator could be called. However the implementation is not allowed to copy assign the T, only move assign it.
0
Q: std::vector::erase exception safety

mborows2I have read that std::vector erase method use move operations only if type is known to not emit exceptions due to strong exception safety. Other comments are that erase method guarantee basic or no throw exception safety depending on that if element constructor throws or not. I wasn't able to cla...

 
user1804599
Eek implicit copies.
 
Looks like the container gets its exception guarantee from the type itself for some operations
 
the worst one is insert of a range in the middle
 
@orlp Why is that bad again?
What does it do?
 
11:53 AM
or emplace in the middle
well emplace constructs an element in-place
and insert of a range inserts a range into the middle
 
@orlp So... can't you just construct it outside of memory and then move it in?
lol but that defeats the purpose of having emplace
Hmmmm
Welp the standard requires strong exception guarantee for vector::emplace soooo
 
we may have to reallocate, we have to move elements, we have to construct an element in place, and update size/pointers
 
@orlp But it needs to pass construction before this
 
at any point all of these can throw
 
@orlp So that means you construct first and then you move.
 
11:55 AM
and you have to undo what you did until that point
@VermillionAzure no you construct once
that's the whole point of emplace
it's constructing in place
 
@orlp But strong exception guarantees that the container is untouched if it fails
 
@VermillionAzure yes, so if an exception occurs, you undo the steps you did before
 
user1804599
Cool, ATS FFI supports C macros.
 
Therefore, if you can fail during any of the process, you either need to make the entire operation reversible or you can just defer everything
 
user1804599
Killer feature.
 
11:56 AM
@orlp Do you really want to have to undo moves?
 
@VermillionAzure no choice
but
 
@orlp Technically you have a choice
 
if you have to reallocate
you have to do it in one go
 
The choice is whether you want to bullshit emplace or not :)
 
otherwise you're moving ranges of elements twice
which is inefficient
and what about insert(pos, begin, end) on a non-random access iterator?
you have to insert into the middle god knows how many elements
 
11:58 AM
@orlp Don't ask me lol
@orlp But what if you don't have to reallocate?
 
Xeo
@orlp VC++ emplace_backs and then rotates it into place :D
 
e.g. say we have capacity 3 and elements 0, 1 are taken. So now what?
If we insert at 1...?
Then that means we move 1 -> 2 and construct in 1, right?
 
@VermillionAzure yes
 
And if that fails, then we have to move 2 back to 1?
 
yes
and if that move fails
 
11:59 AM
Now, that just seems overly complicated.
 
you're fucked
 
@orlp Exactly.
 
Xeo
For inserting a range, VC++ again inserts at end and rotates into place
 
maybe I'll do that as well then
seems simpler to implement
 
Xeo
VC++'s insert is ~20 lines for input iterators
and half of that is exception handling macros + debug checking
 
12:02 PM
@Xeo Wait, what?
How the heck does it do that?
Say you're doing insert (3, 4) at [1] in a size 4 vector... then...?
 
Xeo
literally auto old = size(); for (range...) push_back(val); rotate(where, begin() + old, end());
 
Why would you rotate?
 
@Xeo it still needs to have a try { ... } catch (...) { undo push_back; throw}
 
Xeo
@VermillionAzure To get the stuff from the end to where it belongs
@orlp erase(begin() + old, end()).
 
yeah
just sayin'
 
Xeo
12:04 PM
2 mins ago, by Xeo
and half of that is exception handling macros + debug checking
also ^
 
I'm so confused
 
Xeo
I was simplifying to the actual code for range insertion
 
I need a picture :(
So if I have (1,2) and I'm inserting (3,4) at [1] then...?
It's supposed to be (1, 3, 4, 2) but you're telling me that it goes (1, 2, 3, 4) first?
 
Xeo
First you have (1,2,3,4), then it rotates the last two into place (1, 3, 4, 2)
ye
 
@Xeo Ohhhhh you mean it rotates left? ohhhhhh
And it rotates between the target index and the end? Oh
ohhhhhhh dude it's 2:00am and I am so high on lack of sleep
1
Q: Combinatorics/Probability - Why does this equation work?

VermillionAzure Five distinct numbers are randomly distributed to players numbered 1 through 5. Whenever two players compare their numbers, the one with the higher one is declared the winner. Initially, players 1 and 2 compare their numbers; the winner then compares her number with that of player 3, a...

This terrible thing was keeping me up
And that's just problem 1a
 
Xeo
12:07 PM
insert for forward iterators looks more complicated, but only because of optimisations
 
@Xeo ah, but here is the thing
if you do reserve -> push_back -> rotate for inserting a range
 
Xeo
If there's no need to reallocate, it's basically the same, but uses uninitialized_copy
 
there is an inefficiency
if you need to reallocate
then you're moving elements twice
once to the new location
and once in the rotation
 
Xeo
yes, which is why it doesn't do that when it doesn't have enough space for forward iterators :P
 
@orlp Or you can just use a separate algorithm for reallocation?
 
Xeo
12:10 PM
because it needs to realloc anyways, it can just insert at the right point anyways
allocate new storage
move over first half (until `where`)
copy over new stuff
move over second half (from `where` to end)
 
yeah
I mean, I know how everything can be solved
it's just... ugh
 
Xeo
it's not terribly complicated here
 
I'm not done yet
and I'm already at 700 lines of code for my devector
 
Xeo
VC++'s <vector> header is 1800 excluding vector<bool> :P
 
let's not speak of vector<bool>
 
Xeo
12:14 PM
but that also includes all the debug checking
 
I can assure you there will not be a devector<bool>
yeah
 
Xeo
hrhr
also iterators
I saw you just use raw pointers for those
 
I have no iterators
yeah
not needed
only if you want fancy debug tracking
 
Xeo
ye
 
I still am so surprised
that I've not found any other examples of a devector
conceptually it's pretty simple
 
Xeo
12:16 PM
ringbuffer?
 
it's not
there is no ring, or modulo
 
Xeo
seems like it would also be okay-ish to implement with modulo and just reusing the storage at the end
should also be 4 pointers
first, last, storage start, storage end
 
with modulo it isn't a plain buffer anymore
then you need custom iterators
you can't pass it to C code
etc
 
Xeo
mh
true
 
and every index operation
gets an extra AND on top of it
(and assuming that, you can only have sizes that are powers of two)
if you do not use AND... well, then everything gets a modulo on top of it which is even more expensive
no, the whole point of the devector was to not be a ringbuffer :P
 
Xeo
12:20 PM
What you're doing is just having half the unused capacity at the front, right?
 
@Xeo nope
 
Xeo
oh?
 
there is 0 unused capacity on the front until you do a push_front or pop_front
there is in fact no interaction between the amount of capacity on the front/back
with the sole exception
that if we have plenty of space to hold the entire array in the capacity
but one side has ran out
it can 'steal' half the capacity of the other side, and prevent reallocating
 
Xeo
I see.
Why not steal the full capacity?
 
this is to prevent from getting infinite memory usage if using the devector as a FIFO buffer
@Xeo because this can cause degenerate cases
where if you alternate push_front/push_back
you get a full move on every push
 
Xeo
12:23 PM
mh
 
@Xeo stealing half the capacity isn't bad either, it exponentially steals the capacity 50% 75%, 87.5%, until we need an actual reallocation
oh damn I've lied
every time a side runs out it always steals half the capacity of the other side
even if we're reallocating anyway
this is to 'reclaim' unused capacity of the other side
@Xeo however, all this means that you can use a devector as a regular vector with effectively 0 overhead
since it won't waste capacity on the front
but if you do need to occasionally do a pop_front, or even a push_front, the capability is there to do it efficiently
 
Xeo
@orlp cept for that pointer and some checks which should branch-predict well enough tho, I guess.
 
@Xeo that's what I call 'effectively 0' overhead
do you care that a devector is 32 bytes vs vectors 24 bytes?
or that it assigns two more variables on init? etc :P
the important part (indexing and iterating) is just as fast as a regular vector
something a ringbuffer can't say
 
Xeo
I'm was thinking if you could make things easier on yourself by having your implementation be vector<T>; iterator first;, but the vector would keep the "capacity" at the front constructed, so eh.
 
@Xeo by the way about that rotating...
a devector has two paths for everything
one for the front, one for the back :P
this halves the amount of rotating needed on average
 
Xeo
12:36 PM
heh
 
insert(begin+size()/4, ...) is just as fast as insert(begin + 3*size()/4, ...)
 
Xeo
@orlp But only if there's capacity at the front, no? Otherwise it should behave the same as vector.
 
@Xeo the first time :)
if it happens once
no one cares
if it happens more often, the devector will start allocating size for that end
 
Xeo
Now I'm wondering about "usage-guided" allocation policies
 
what do you mean?
 
Xeo
12:42 PM
Like, keeping track of whether the user needs the front or the back more, and shifting capacity around wrt that.
 
@Xeo well the thing is
the devector does that organically
by constantly stealing from the other side
 
Xeo
true
 
'but what if I use both sides equally?'
well, if that's true, then there won't be any free capacity to steal once you trigger the push_front/back that causes a resize :)
until it happens to the other side
if you do the worst case
where you alternate attention of sides in the worst way for the allocation
hrm, I don't know what the limit is
at every iteration the total size grows by 1.5
 
good afternoon
gentlemen, could someone assist me with gcc intrinsics?
 
if you're here for help you've come to the wrong place
 
Xeo
12:46 PM
@orlp Yeah, and if the devector tracked usage, it could split that up equally to front and back
 
@Xeo I don't want to, though
I think the organic system will be fine pretty much in all cases
 
Xeo
Yeah, I was just thinking.
 
and the worst case is 50% slower on reallocations at worst
 
Xeo
Like, at what point would it be benificial to have?
 
and I don't think that really happens
 
Xeo
12:47 PM
Btw, what do you do on reserve?
 
@Xeo reserve is an alias for reserve_back to be compatible with vector
 
Xeo
I see
 
there is a separate function reserve_front
and a new overload
reserve(front, back)
that does both in one reallocation
 
Xeo
Sounds good.
 
only thing I'm conflicted on
is capacity()
should that also be an alias for capacity_back()?
to be compatible with vector?
and make another function total_capacity() for the total capacity?
because the thing is, knowing the total capacity isn't too useful in general
(and can be calculated with capacity_back() + capacity_front() - size())
 
Xeo
12:50 PM
Whole capacity would be fine, I think. Capacity only tells the user at what point a reallocation happens and their pointers get invalidated.
 
yeah, but that's not what whole capacity means.
 
I'm more tempted to alias it to capacity_back()
@Puppy ?
 
you need to reallocate or move objects after filling up the capacity in only one direction.
so I think it should be the minimum of the two capacities.
 
@Puppy well yeah
 
12:51 PM
there is capacity_back and capacity_front
 
you guys are busy now
 
the question is what should capacity() be?
 
yeah, I know.
42 secs ago, by Puppy
so I think it should be the minimum of the two capacities.
 
I think an alias to be compatible with vector is sane
oh
I thought you mean there needed to be at least two capacity functions
ehh I don't like the 'minimum' idea
 
Xeo
In the end, it all gives a wrong idea, I guess.
 
12:52 PM
who would ever call that function?
 
Xeo
maybe leave out capacity, so it can't be misunderstood?
 
@Xeo unacceptable
 
I guess it depends on exactly what you want.
 
I want devector to be a drop in replacement for vector
I guess that answers my own question then
 
purely for compatibility with vector's interface, people effectively expect capacity_front() == 0, so there's no harm in making it be capacity_back() only.
 
12:54 PM
I'll also add total_capacity
err
capacity_total
also, my god, the rate limiting on stackexchange chat is way too fucking aggressive
 
Xeo
yes
It's annoying as fuck
 
total_capacity is way better.
 
@Puppy but isn't following the pattern
 
who cares?
 
me =/
 

« first day (2171 days earlier)      last day (2770 days later) »