« first day (741 days earlier)      last day (4212 days later) » 

4:00 AM
There is no actual list, I'm doing C++. Used Haskell to double-check your algo for the convenience.
 
Xeo
Wait, I'm confused. Why do you want -2 % 3 == 1 again?
 
Passing stuff to std::get.
 
Xeo
ah, wrapping index access
 
I'm slicing tuples, slice<FromTo<-2, 0>>(tuple) slices the two last elements, in the original order.
@Xeo Exactly.
 
Xeo
But, what do you need modulus for?
For when the indices are (absolutely) larger than the tuple size?
 
4:07 AM
Oh fuck, I just enabled that as a side-effect.
No it's for negative indices.
 
Xeo
Yeah, but why modulus? Wouldn't size + neg_index work?
(For the negative index case only)
 
I lost scope. I naively used %, but that wasn't quite the modulo/remainder operation I needed, so I investigated the matter.
As you point out, I can do (i + n) % n and cover my needs, i.e. [-n, n).
 
Xeo
A branch (test if negative) vs modulus is just a matter of taste here, right?
 
What's the point of doing that?
 
Xeo
Well, my thought was that you only need to wrap the index if it's negative
So a branch came to mind
 
4:13 AM
I don't modify anything, I compute.
 
Xeo
I didn't mean "modify" in that sense. I meant that you need to compute the correct positive index only if the index is negative to begin with.
 
Ah right, I effectively cover [-n, +inf) right now.
 
Xeo
return i<0? size+i : i; vs return (size + i) % size;, and my thinking was that choosing either is just a matter of preference (if you precondition that i always falls in [-size, size))
 
size-i is wrong.
 
Xeo
right, typo
 
4:18 AM
No, not a typo :p
I'm not sure if I actually want [-n, n) as a precondition, and if so, how/where to enforce it anyway.
 
Xeo
static_assert(-size <= i && i < size, "...") inside the function?
 
The size is the divisor, and is a tuple size.
 
Xeo
?
 
template<int... Indices, typename Tuple, int Size = std::tuple_size<Bare<Tuple>>::value, Requires<And<Bool<(-Size <= Indices && Indices < Size)>...>>...> is kinda long-winded, isn't it?
 
Xeo
I meant inside the function that does the wrapping
 
4:24 AM
I have a version of slice that takes indices individually.
Hence support for both slice<-3, 2, 0>(tuple) and (slice<FromTo<I, J>>(tuple).
Wait, that's the wrong way to put it.
I have a version with non-type parameters, and a version with a type parameter.
 
Xeo
constexpr unsigned wrap_index(int i, unsigned size){
  static_assert(-size <= i && i < size, "...");
  return i < 0 ? size+i : i;
}
was my thinking for enforcing the precondition.
 
FromTo being an alias for indices<I, I + 1, ..., J - 1>.
@Xeo Not a constant expression.
 
Xeo
Why not?
 
std::cin >> i; wrap_index(i, 42);
 
Xeo
ahh, damn. I always forget that for whatever reason.
 
4:32 AM
No reason I can't turn it into a metafunction, except that the implementations sure are going to look ugly.
 
Xeo
template<int I, unsigned Size>
struct wrap_index : uint_<(I < 0)? Size+I : I>
{
  static_assert(-Size <= I && I < Size, "...");
};
 
Xeo
it is, then
 
I'd rather Conditional<C, R0, R1>.
In fact you can just if_c</* ... */>::type in there.
Ah well, lazy vs eager.
 
Xeo
Why another metafunction at all
damn router timeouts
 
4:35 AM
Wot?
 
Xeo
Seen my edit to the wrap_index code?
I got some router connectivity problems while editing
And now I wonder why I even thought of inherit_if at all.
 
I also have problems on my end, for added fun.
 
Xeo
heh
I think that metafunction isn't really ugly
 
template<typename Tuple, int Size = std::tuple_size<Bare<Tuple>>::value>
std::tuple<typename std::tuple_element<mod(Indices, Size), Tuple>::type...>
static slice(Tuple&& tuple)
{ return std::tuple<typename std::tuple_element<mod(Indices, Size), Tuple>::type...>(
        std::get<mod(Indices, Size)>(std::forward<Tuple>(tuple))... ); }
Substitute mod(x, y) with mod<x, y>::value.
(static because this is a member of an implementation detail that pattern-matches over indices<Indices...>.)
 
Xeo
Damn explicit ctors! :P Or rather, damn list-initialization for not selecting them
 
4:43 AM
Ya, the make_slice and forward_slice version are nicer.
 
Xeo
Btw, you said you get the slice in the original order, but this seems to slice in the reverse order if you specify a negative first index
 
I don't get it. [-n .. 0) maps to [0, n), doesn't it?
Test is fine btw.
If you were to slice<-1, -2, -3> then yes that would be reverse order.
 
Xeo
Hm, question, how does FromTo<-1,0> generate the indices?
 
offset<From, generate<To - From>::type>. No support for e.g. FromTo<5, 0> atm.
offset<Base, indices<Indices...>> is indices<Base + Indices...>.
This definition has the added benefit that you have a high chance of hitting previous instantiation of generate!
So if you've computed FromTo<1, 4> then FromTo<2, 5> only costs an additional offset instantiation!
 
Xeo
Okay, can I get the exact list FromTo<-1, 0> would yield?
 
4:55 AM
indices<-1>
FromTo<I, J> is [I, J).
 
Xeo
Right, you mentioned that reverse slicing wasn't working yet
I kinda confuzzled myself there
And to support reverse slicing, you'd need to do reverse<generate<To, wrap_index<From, Size>::value>::type> if From > To or From < 0
Or generate the list in reverse to begin with
hmm..
 
Ya, I'm investigating -generate<-To, -From>::type
I think that works?
 
Xeo
Huh? I thought generate was an unary metafunction?
 
Oh sorry, -FromTo<-To, -From>.
 
Xeo
Sounds correct
Wait
 
5:06 AM
I meant -FromTo<-From, -To>, but that seems to be in the wrong order.
 
Xeo
Gah, if only LWS was up
 
I don't get it, I get my expected results in Haskell :|
 
Xeo
I may just have a wrong thought here
 
> error: conversion from 'tuples::FromTo<0, -4> {aka indices<0, -1, -2, -3>}' to non-scalar type 'main()::<anonymous struct>' requested
 
Xeo
Right, the reverse order is missing here
 
5:11 AM
It's not, it's in decreasing order.
Okay, I've established it's correct for positive indices.
 
Xeo
wait, that indices list on tuple<_1, _2, _3, _4> would yield tuple<_1, _4, _3, _2>, wouldn't it?
 
wut
 
Xeo
(together with wrap_index)
 
Yes, I'm witnessing off-by-one errors.
That's because [i, j) naively reversed to [-j, i) is wrong. Cf. reverse_iterator.
 
Xeo
aye
 
5:13 AM
Let's try +1. Because.
 
Xeo
Better just generate the indices in reverse.
 
You crazy. More instantiations?
 
Xeo
:)
Would make it a lot easier, atleast.
First get it working and worry about optimizations later
 
Hey guys, I've run into a quick thing that's bothering me about virtual functions and their overloads.
It... seems like if I overload a function Baz inside a class named Bar from a base class Foo, then I can't call other variations/overloads of the method Baz without explicitly overloading it in Bar
 
Xeo
template<int I, int N, int... Is>
struct rgenerate : rgenerate<I+1, N, Is..., I>{};
template<int N, int... Is>
struct rgenerate<N, N, Is...>{ using type = indices<Is..., N-1>; }; // N-1 may be wrong here
 
5:19 AM
@ThePhD That's true (whether the functions are virtual or not). If you want the base class functions to be visible in the derived class, you can add using Foo::Baz; to Bar.
 
@Xeo More seriously it's not a matter of generating indices -- I get those. It's not clear what semantics I want though, when taking into account the modulo.
 
@JerryCoffin If I don't explicitly add using Foo::Baz to Bar, how do I access it from the outside from a Bar object?
 
Xeo
@LucDanton Well, intuitively I'd expect slice<FromTo<-1, 0>>(tuple_5) to generate indices<4, 3, 2, 1, 0> and slice<FromTo<0, -1>>(tuple 5) to generate indices<0, 1, 2, 3, 4>, if that's what you meant.
 
@ThePhD I'm not sure what you mean by "from the outside from a Bar object".
 
@Xeo FromTo<-1, 0> is <-1>.
 
Xeo
5:22 AM
Wait, weren't we trying to make that work like in Python, aka reverse slicing?
I may have gone completely off-track if not
 
Not necessarily, no.
 
Xeo
What, me being off-track or making it do reverse-slicing? :P
 
We want some semantics for sure. We get to decide which!
 
Xeo
/votes for Python-like slicing
 
@JerryCoffin I mean like in this example
 
Xeo
5:24 AM
8
Q: Why do multiple-inherited functions with same name but different signatures not get treated as overloaded functions?

XeoThe following snippet produces an "ambigious call to foo" error during compilation, and I'd like to know if there is any way around this problem without fully qualifying the call to foo: #include <iostream> struct Base1{ void foo(int){ } }; struct Base2{ void foo(float){ ...

I have a feeling this is relevant in some way /cc @ThePhD, @JerryCoffin
No more slicing votes? Cool, win by default! /cc @Luc :P
More seriously, I think that's just more intuitive than slice<FromTo<-1,0>> being equal to get<-1>
 
I think I've actually got it working for quite some time now but I've been misinterpreting the results of my text.
 
@ThePhD Yes: b.Foo::Baz( 0xdeadbeef );
 
@Xeo That way is more regular. Can you express in Python what you want to specify?
s[-1:]?
 
@JerryCoffin Ooh.... so I can't expect method lookup to be fowarded into the scope of it's derived classes.
That's unfortunate.
 
Xeo
@LucDanton That would do reverse slicing, IIRC
okay, it does not
 
5:28 AM
@Xeo What we're talking about right? Although I actually only get one element...
 
Xeo
fuckit, my understanding was wrong the whole time
 
[-1::-1] does that kind of slicing. Might not be the most idiomatic though.
 
Xeo
and s[-1:0] gives... 0 elements
oh, wait, -1 is actually not the last element with python.
 
Is it not?
Appears to be on my end.
 
Xeo
atleast not in s[0:-1]...
 
5:29 AM
Also apparently [::-1] is the idiomatic way to get a reversed slice.
 
@ThePhD Presumably you mean base classes? If so, no. Once it finds a scope at which there's a matching name, it collects the names in that scope, and treats them as an overload set -- it does not continue searching other scopes after it finds a match. Otherwise, it would just about have to disable most (all?) implicit conversions.
 
Xeo
I honestly thought s[-1:] would reverse it
 
@JerryCoffin True, that could present quite a problem.... well. I understand how it works now. I think in most cases I'd have to forward the scope into the derived class; I don't have any things that are clashing.
 
Xeo
Ah, with Python's slicing [0:-1] is actually [0, size)
 
@JerryCoffin Thank you for the help. And thank you @Xeo for the additional information.
 
5:31 AM
Consider something like:
int main() {
int i;
i = 0.0;
}

Then if I add a global double named `i`, suddenly my assignment would be to the global instead of the local -- the whole meaning of code that's been tested forever suddenly changes completely.
 
Xeo
that's why s[0:-1] only yielded N-1 elements
 
@Xeo size - 1
 
Xeo
@LucDanton Note half-closed range
 
Yeah, it makes sense when you put it in that context.
 
@Xeo s[s.size] is what element?
 
Xeo
5:32 AM
out-of-range error
 
So [size - 1] is the last element.
If I slice [0:-1] the slice stops at the penultimate element, not last.
To me that's [0, size - 1)
 
Xeo
sigh, my brain is not working correctly anymore it seems
I was mixing up size with the highest index
 
Fenceposted!
 
Xeo
:s
Okay, so we can note s[-1:] yields the last element and is equivalent to s[-1].
 
To the extent that the first is a slice, second is an element.
 
Xeo
5:36 AM
aye, right
s[-1:][0] == s[-1]
 
I think I'm only missing reasonable defaults now. Like how [:] is slice of everything, [3:] is slice from [3] on etc.
I already have To<N> as an alias to FromTo<0, N> but that only works for non-negative N.
 
Xeo
You can't really give the second parameter of FromTo a default without knowing the size
 
Yup.
 
Xeo
change em to classes and have template<class From = int_<0>, To = end_of_seq>? :D
 
If those weren't non-type parameters I could pick any kind of type as a placeholder.
Great minds etc.
 
Xeo
5:40 AM
Thinking about it, that still wouldn't work, would it? FromTo has to generate an indices pack, and end_of_seq still doesn't tell it the size of the tuple
 
Yeah that's where it's gonna suck: coupling.
 
Xeo
Oh, wait, you got the implementation of slice partially specialized on FromTo, don't you?
 
Whereas FromTo<I, J> generates an indices pack some things will have to generate a 'lazy' placeholder with the partial information and the implementation of slice will have to fill-in the holes.
@Xeo On indices only currently.
 
Xeo
May be worth it to do the same for FromTo so it acts as a placeholder only
then you can generate<From, replace_eos<To, Size>::value>::type
 
By this point though, I want to consider the interfaces.
 
Xeo
5:43 AM
Yeah, if you changed to classes the user would need slice<int_<0>, int_<4>> :/
 
I can have explicit_slice<0, 3, 2, 4> for passing the indices directly.
 
Xeo
So no "overloading" on FromTo it seems.
 
And slice<1, 3, -2> for what is currently the type parameter version of slice.
(Assuming hypothetical support of strides.)
 
Xeo
What does the three paramter version do anyways?
oh, that answers it
 
Isn't Python your golden standard? :p
 
Xeo
5:44 AM
I don't actually know Python, as you have seen with my failing wrt reverse slicing. :P
 
Oh wait, that idea works if you omit later parameters, i.e. slice<3> to match [3:]. Doesn't work for [::-1] though.
 
Xeo
Why the heck does s[0::-1] yield something different from s[::-1]?
nvm
gaah
 
It is my understanding that [::-1] is the same as [slice(None, None, -1)] and there's the same kind of 'fill in the holes' logic.
I.e. negative stride means reverse slicing, which starts from -1.
 
Xeo
Nah, it makes sense, it walks backwards from [0] to [4], which is just 1 element
 
I can't fault the design tbh.
 
Xeo
5:47 AM
s[4::-1] yields the reverse list
I think I'm fine now.
Python does magic, accepted.
 
Ya, 4 or -1 being the same modulo 5.
So template<typename From = void, typename To = void, typename Stride = void> is the same as the :: syntax sugar which plugs None for missing args, but is extremely ugly for the client to use.
 
Xeo
Yeah
 
I suppose I can coopt INT_MIN :(
 
Xeo
:s
Damn special values
 
Still a problem for a client to pass e.g. ::-1.
I think I'm going to stick with aliases.
 
Xeo
5:49 AM
Might be the best
 
slice<FromTo<i, j, [k]>>, what else?
slice<To<j, [k]>> which omits From?
and finally slice<Across<[k]>>?
 
Xeo
slice<FromTo<i[, j[, k]]>>, right?
 
Oh yeah!
I need something for i, k now.
slice<From<i, [k]>> I guess.
 
Xeo
nvm my notation, you know what I mean
Mhm
From<i>::To<j>::Stride<k>? :)
Freely interchangeable?
 
Ya that works.
template<int J> using To = FromTo<i, j>;
The question is now, shall I forget about a 'complete' FromTo<i, j, k> generating the relevant indices?
That would tie this FromTo feature definitively to slice.
 
Xeo
5:54 AM
You mean only using it as a placeholder?
 
Yes.
 
Xeo
Well, since you got no special values in FromTo for now, I don't think you should
 
On the other hand the whole motivation of me writing this is trying to encourage the use of indices.
 
Xeo
You can do both, but that would be silly, I think
 
It's true that for the time being only slice explicitly accept indices in its public interface. I can't imagine any other feature using it.
transform(FromTo<i, j> {}, tuple, f) can just as easily be expressed as transform(slice<FromTo<i, j>>(tuple), f).
 
Xeo
5:58 AM
I was just wondering, why take FromTo as a template parameter anyways in slice?
 
Because compile-time. Also see: std::get.
 
Xeo
So? The values are still compile-time constants if you do slice(FromTo<i, j>{}, tuple) as in the transform snippet
Consistency might be an argument, though
 
Ya sure. But I want to mimic std::get here. I changed the style for transform as a reference to how those delegate to an implementation by passing IndicesFor<Tuple> {} or whatever.
 
Xeo
mhm
 
Btw slice<-1>(tuple) can be abused to be a more convenient std::get<std::tuple_size<Bare<decltype(tuple)>>::value - 1>(tuple), sort of.
 
Xeo
6:01 AM
aye
Or you could name it get in the first place. :D
You're missing a -1 there btw.
 
If not for that explicit constructor (again), slice<-1>(tuple) = { 42 }; would work, too.
Stupidly it works for tuples of size 2. That is to say, slice<i, j>(tuple) = { a, b };.
 
Xeo
@LucDanton Huh, I thought the whole Args&&... ctor was explicit?
 
@Xeo std::tuple<T, U> has a pair-like interface.
@Xeo Would you let get<I>(tuple) a 1-tuple or would you let that degenerate to an element?
 
Xeo
It selects the operator=(pair<...>) overload, eh?
 
Oh, a case for calling it silce is that there are make_slice and forward_slice sibilngs.
 
Xeo
6:04 AM
@LucDanton Good argument
 
@Xeo I dunno. Perhaps. It's magical! And I should really double-check those claims tbh.
 
Xeo
btw slice<-1>(tuple) = { std::allocator_arg, {}, 42 }; might just work
 
l o l
 
Xeo
Hey, I was just looking at the list of ctors!
 
> Requires: Alloc shall meet the requirements for an Allocator.
{ std::allocator_arg, nullalloc, 42 } is the obvious answer.
 
Xeo
6:08 AM
Aye
 
Introduce a conversion from nullalloc_t to std::allocator_arg_t and suddenly { nullalloc, nullalloc, 42 } is possible. Genius!
 
Xeo
But now we're getting silly
 
I'm actually giggling like an idiot.
It's a kind of passive protest coding.
 
Xeo
You'd get problems with actual containers in the tuple, though.
 
Oops.
Oh yeah that sucks.
 
Xeo
6:10 AM
hmm
struct nullalloc{
  template<class T>
  operator std::allocator<T>() const{ return {}; }
};
 
I have a problem that I currently have bool reversed = (From > To) as an implementation detail of from_to.
 
Xeo
Actually, why not just an unbounded one. What could go wrong?
 
posted on October 26, 2012 by Anders Schau Knatten

A few weeks ago I introudced private inheritance, and finished with a comment about a common excuse for using it. In this post I give an example of such usage, and discuss whether it is a good idea or not. Say you are going to write a new class CppInfo, which will print out some [...]

 
Xeo
@LucDanton What are you using that one for?
 
Specialize for decreasing indices.
 
Xeo
6:14 AM
ah
 
Okay currently increasing FromTo<From, To> is offset<From, generate<To - From>>. Can I special case generate<N> for negative N such that the above still works for decreasing indices?
 
Xeo
I think so?
 
FromTo<-2, -5> is -2 .. -4, we want to match that with x + [-n, 0) and identify x and n.
 
return &quot;Language: C++\nCreator : Bjarne Stroustrup\nQuality : ??&quot;;
lol
 
That's x = -5 and n = -3, isn't it? Yes, it took me that long.
So FromTo<From, To> needs to be x + generate<To - From>, where x is what? The max of From, To?
Ah, min apparently. That is to say, From for increasing indices, To for decreasing indices.
 
Xeo
6:22 AM
Sounds about right
 
And generate<-N> needs to be indices<-N, -N + 1, ..., -1>
Mmmh, I'll work on that later. Let's implement all that and check what breaks.
 
Xeo
heh
I think I'll just go an start "Operation: Test pillow fluffyness" here.
 
Noes, I need you!
 
Xeo
lol
But my brain's fried and I can't think correctly anymore without thinking wrongly 3 times. :(
 
Oh ya, [-N, -1) is N + [0, N - 1). That was actually easy.
How surprising, it doesn't work on the first go.
> error: no match for 'operator=' (operand types are 'main()::<anonymous struct>' and 'tuples::FromTo<-4, 3> {aka indices<-4, -3, -2, -1, 0, 1, 2>}')
Actually...
Wait, that's increasing, I'm dumb.
> error: no match for 'operator=' (operand types are 'main()::<anonymous struct>' a
nd 'tuples::FromTo<-4, -8> {aka indices<-12, -11, -10, -9>}')
Okay so the bug was that I need to select From as an offset for decreasing indices. I expressed that as a min earlier but I messed up. Simpler to express what I need naively with a conditional: (To - From) < 0 ? From : To
Lol, other way around. I even messed up transcribing my findings.
ihavenoideawhatimdoing.jpg
Operation debug by adding minus signs and shuffling parameters around randomly.
Okay, implement generate<-N> as -generate<N> and FromTo<From, To> as From + generate<To - From> and that's it.
And that should be it for the time being.
 
7:11 AM
 
7:26 AM
Morning all!
 
morning
not sure I need a lick bath, but thanks for the offer
 
Apparently Jeff Atwood loves Markdown
 
you need a blog post to tell you that?
 
@thecoshman I merely posted a cute picture of a Lioness doing her thing with a baby. I did never mean to imply I was going to even remotely consider giving anyone a lick bath.
@thecoshman the blog post merely verified that fact in stone for me
this is kind of cool
 
@TonyTheLion he could still be lying
but I just got a rasPi, well it's on it's way
 
7:42 AM
@thecoshman he could be, but I'm just gonna take that he isn't
 
@TonyTheLion well, it is the most likely
 
lol
Where is everyone this morning?
eh my right foot seems rather painful today. Meh
 
mornin'
 
mawning
 
@TonyTheLion they playing up again? You've not commented much about pain recently, so either they have been relatively ok, or your job has been sucking that much (feel free to tell me to drop it)
 
7:54 AM
@thecoshman I just try not to bitch too much about it. People get tired of hearing yet again that it hurts. They hurt in varying degrees, but today seems more than average. Well, the suckiness of the job has got me to complain about that more.
 
on the plus side, this exists
 
@LuchianGrigore huh...
@TonyTheLion perhaps set up a twitter account to post about how your feet are feeling? I've seen stupider things
 
@thecoshman hehe
 
@TonyTheLion @TonysFeetHurtThisMuch
:( had a typo on my profile page
 
8:11 AM
lol
 
8:49 AM
oh dear, I fear I am about to get into a rather epic war at work about why distinct units of work should be managed on their own branch, rather then just as edits to a checked out version of the latest on the main
 
I am surprisingly wound up
 
go flip some tables
 

« first day (741 days earlier)      last day (4212 days later) »