« first day (711 days earlier)      last day (4242 days later) » 

4:00 PM
@Xeo No, it doesn't. non_pod1 has stricter alignment than char (it has a vptr :P).
 
Xeo
Oh, alignment
Fuck alignment. :(
 
No, fuck reinterpret_cast.
 
Xeo
And I forgot that almost every type is a POD with new rules
 
Can you static_cast in constexpr?
 
Xeo
I think so
I know you can't reinterpret_cast, but static_cast should be fine
 
4:06 PM
template <typename To, typename From>
constexpr To* safe_aliasing_cast(From* from) {
    static_assert(wheels::can_alias<From, To>::value, "cannot alias these types"); // this trait needs magic :(
    return static_cast<To*>(static_cast<void*>(from));
}
template <typename To, typename From>
constexpr To* mjollnir_cast(From* from) { // Mjollnir is Thor's hammer
    return static_cast<To*>(static_cast<void*>(from));
}
 
@R.MartinhoFernandes why the two versions, I don't see an immediate difference besides the static_assert?
 
@Xeo May need some polishing.
@MooingDuck Right, that's intended: one is safe, the other is reinterpret_cast, but more powerful (well, it misses the pointer -> int bits, though).
 
Xeo
@R.MartinhoFernandes Should just be From&& and To, since you should be able to cast references, methinks
 
Xeo
oh :)
 
4:08 PM
The nasty is the can_alias.
There's no way to know the type of the first member.
 
Xeo
aye
yeah, static_cast is fine, just checked
Btw, there may be some kind of way to get the narrowing conversion stuff working through constexpr
 
what the, wikipedia has a "Drawing of a 4.6 cm gold-plated silver Mjölnir pendant..." Who cares what the origional is made of, if I'm looking at a drawing?
 
Xeo
> conditional-expression is a core constant expression unless it involves one of the following as a potentially evaluated subexpression (3.2) ... :
> - a result that is not mathematically defined or not in the range of representable values for its type;
 
@Xeo But that can only cause a hard error, no?
 
Xeo
And then force the function to be constexpr by using it, say, as a template argument
Extended SFINAE says that any compiler error during substitution is SFINAE
 
4:11 PM
@MooingDuck Well, you get to know one such pendant existed and had silver and gold.
@Xeo Do you know what the "in the immediate context" bits mean?
> Only invalid types and expressions in the immediate context of the function type and its template parameter types can result in a deduction failure.
 
Xeo
Know what, why don't we just try if this leads to SFINAE
 
(I don't know, I'm just annoyed that it might mean something I won't like)
 
@R.MartinhoFernandes it's a drawing of a pendant of a hammer, in an article about a hammer. I don't care about the pendant :P
 
Xeo
@R.MartinhoFernandes template<class T> void f(typename some_template<F>::type*=0)
is immediate context
if some_template is like enable_if
 
@Xeo Right, but will the body of the constexpr function be an immediate context?
 
Xeo
4:13 PM
however, if it is implemented as follows, it's not
template<class T>
struct some_template{
  typedef typename T::type type; // not immediate context if T has no nested type
};
@R.MartinhoFernandes oh, good question. I think? :|
 
For example, static_asserts are always hard errors.
 
Xeo
right
Btw, can floating point types be used in constexpr contexts?
 
Yes.
Hmm, I can reduce the false positives of can_cast by checking alignment.
Wait, which is better? False positives or false negatives?
 
Xeo
false negatives, I guess
you'd rather be more restricted than less
 
In that case I can't accept any first member aliasing.
Need moar magic traits!
 
4:20 PM
@Xeo me too, I'd rather code a workaround for an assert than have bad code silently "work" :/
 
0
Q: Difference between singleton methods

Viniyo ShoutaIs there any difference between these methods, other than the obvious that first return an object and second returns the address where the value of myclass is stored? I'm asking because I rarely see the first method, in many sources, even of big enterprises such as Aeonsoft I always see method 2 ...

 
There's a current proposal that includes letting you know the type of the first member.
 
Check out the edit he made, changed the meaning of the whole question after getting about 6 answers
 
Oh fuck. Serial upvoter strikes again.
 
Here's another one:
// is this allowed?
int * n = static_cast<int*>(malloc(sizeof(int)));
@R.MartinhoFernandes I thought it was only allowed to cast from T * to void* and back to its original type.
 
Xeo
4:23 PM
LWS is broken again. -__-
 
Yes, malloc returns void*.
 
@R.MartinhoFernandes Will that get rolled back, or does the algorithm only work for downvotes?
 
@Prætorian Yes, it will most likely be rolled back.
At least I got a badge and those stick :)
 
Xeo
@R.MartinhoFernandes And you'll lose it again
 
(Last time I got 17 badges for free :P)
@Xeo Nope.
You never lose badges.
 
Xeo
4:25 PM
1
Q: Badge details showing wrong value

avasalI earned the python badge 2 days ago, now I can't find it in my profile. User name summary says I have 13 badges, but my badge list in my profile only shows 12. Where is my missing badge? :'(

Oh, wait, tag badges
What kind of badge did you get?
 
@Xeo Ah, well, it's a Nice Answer one.
 
Xeo
:/
 
The other time it was a bunch of Nice Answers and some Enlightened.
 
Xeo
Oh hey, I got a "good answer" one for my copy-paste answer from MS's stdlib implementation
Btw, one guy mentioned "a linked list of shared_ptrs" once when talking about why weak_ptr is not for breaking cycles. I think it's actually rather possible to do such a thing and not have un-cleanable cycles.
I've been thinking about a "floating" linked list with automatic memory management for a while already
 
@Xeo weak_ptr can only break statically detectable cycles.
Unless you add another level of abstraction on top, that is.
 
Xeo
4:29 PM
@R.MartinhoFernandes It's not for cycles, really.
It's for observation
 
ohai guise
 
Xeo
Although such a floating linked list would have cycles of shared_ptrs, but those can easily be resolved
Atleast I hope, I think I need to implement that
 
A linked list with cycles?
Are you talking about graphs?
 
Xeo
nah
 
4:31 PM
What kind of linked list is that then?
It certainly doesn't sound like one.
 
Xeo
A C-style linked list, without a specifc "list" container, but with automatic memory management
Maybe I'm just confused, though
 
@Xeo Still don't get it. Like std::list?
 
Xeo
Yes, but without std::list, aka only the iterators that keep the content alive as long as the iterators are in-use
hm.. crap. I just remembered boost::shared_iterator that keeps a shared_ptr to the underlying container
 
I don't think you can do that.
 
@Xeo I've done that with shared_ptrs, it was a chain of buffers for something
 
Xeo
4:34 PM
@MooingDuck And that's what I want to do
 
Say, if you have an iterator to the middle, how do you keep the beginning alive?
 
Xeo
prev is also a shared_ptr
 
@R.MartinhoFernandes oh, mine was forward only, if you lose the beginning, it's simply deleted
 
@Xeo Then how do you break the N cycles?
@MooingDuck Ah, that is feasible.
 
Xeo
@R.MartinhoFernandes .unlink() .reset()s the links from the neighbors
 
4:35 PM
@Xeo when?
 
Xeo
I see the problem.
Don't ask how I could overlook that.
 
Xeo
I was literally thinking "when the last goes out of sco.... wait."
 
You need a root somewhere (and BAM you're back to std::list :P).
 
Xeo
needs special shared_ptrs
With a flag wether they're sharing with inside the floating list or outside, and the last outside one cleans the whole list up
Just some loud thinking here
 
4:38 PM
@Xeo Erm, what if I have an iterator to the beginning and another to the middle, and destroy the middle one? I don't want my list to die.
 
Xeo
@R.MartinhoFernandes Well, the middle one wasn't the last outside one, was it?
 
@Xeo It was the last outside one for that node.
All iterators need to share the same refcount (BAM std::list again).
 
Xeo
hmpf
I want to get around that somehow
 
What you can do is have all nodes share ownership of a weak_ptr (shared_ptr<weak_ptr<something>>, wow), that the iterators lock on.
 
Xeo
where something is the refcount type, right?
 
4:41 PM
When the last shared_ptr of that weak_ptr dies, it deletes the first node (and the nodes own the next one, not the previous).
@Xeo Can be void. All you want is a custom deleter.
 
Xeo
I thought about having the refcount of the nodes point to a shared "outside" refcount for the list
 
@Xeo And reimplement ref-counting? Pft.
 
Xeo
sure!
 
This is basically std::list again, but the "root" is owned by the nodes.
It's too complex a contraption for literally zero benefit, but it sounds fun.
 
Xeo
4:43 PM
@R.MartinhoFernandes I cite from my chat profile:
> Madness within.
@R.MartinhoFernandes It just reminds me of those lists from functional languages which are garbage collected
 
@Xeo No, seriously, using refcounter = std::shared_ptr<void>;.
 
Xeo
(that's where I go the idea from, btw)
 
user784668
@Xeo Hint: garbage collected.
 
Xeo
@Fanael I know
 
Xeo
4:45 PM
Damn, where was that blog post about self-referencing computation lists from Haskell..
 
what an idiot ^
 
Ell
the stupidity of some people is simply astounding
 
> UCS’s examination finds that the misleading citations include broad dismissals of human-caused climate change, disparaging comments about individual scientists, rejections of climate science as a body of knowledge, and cherry picking of data. Fox News Channel citations also included several discussions in which misleading claims dominated accurate ones.
 
user image
3
@sehe's kid ^
 
Ell
and what's this about deadmg fucking a dude?
 
4:47 PM
@Ell don't ask :P
 
Xeo
@Ell Click the timestamp, read the context (note: The Lonely Island)
 
@Ell So what if he likes men?
 
Xeo
robot, do you know which blog post I mean?
nvm, wasn't a blog post:
14
A: self-reference in Haskell functions

Don StewartI'll trace the evaluation for you: > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) With: > zipWith f (a:as) (b:bs) = f a b : zipWith f as bs > zipWith _ _ _ = [] > tail (_:xs) = xs > tail [] = error "tail" So: fibs = 0 : 1 : zipWith ...

 
Xeo
Anyways, dinner.
Back to science after the commercial break!
 
4:49 PM
@Xeo "recording values that have been computer"
 
@R.MartinhoFernandes Nope FTFY
 
Ell
@EtiennedeMartel I was just wondering really
 
@EtiennedeMartel Bestiality?
 
excellent, the source control server ran out of hard drive space. Todays going to be a good day.
 
4:52 PM
Wut.
Fuck.
How the heck can that happen. Storage is cheap these days.
 
Keyword: Source control
Versions upon versions of file upon file, hundreds of thousands of millions of .cs, .h, .cpp, .d, .ini .proj .eproj .tt THE MADDNESSS
 
@R.MartinhoFernandes because half our servers are virtual servers and nobody remembers what physical machines they're actually on. So they run out of hard drive space completely unexpectedly.
 
@ThePhD Text is highly compressible, and text deltas are cheap.
 
@R.MartinhoFernandes Doesn't it still stack up eventually, though?
 
@R.MartinhoFernandes also, perforce keeps a full copy of every version of non-binary files. And I work with 45MB wave files a lot at my job.
 
4:56 PM
Hint: Perforce is not good.
 
@ThePhD 1TB should be enough for... eons? of source code. Binary files is another matter.
 
Well, if you're working with Wav files, you're screwed. You can't really delta a wav file from another effectively.
 
@MooingDuck Presumably where you said "non-binary" you meant something like "binary" or "non-text"? As badly as P4 sucks, I'm pretty sure it can/does use deltas of text files.
 
Also, I don't know what Perforce is, so I'ma go look it up.
 
@JerryCoffin er, yes. Non-text.
 
4:57 PM
Don't.
It sucks and you have to pay for it.
 
I know the temptation - spend ages cleaning up and archiving to permanent media, or just buy another €80 disk...
 
@ThePhD I assure you, each checkin I'm only changing a contiguous block of about 1/2000th of the audio. So a delta would be significantly smaller in my case :(
 
@ThePhD Look very carefully, so you can be sure to forget it all, and not retain even the single most minor detail.
 
I see Perforce is not popular. I shall abstain from using it.
 
Binary deltas are possible, too.
 
4:58 PM
You know what I really want, though?
A Version Control that runs like Dropbox.
 
0
Q: More elegant solution for multiple bit shifts

NanomurfLet's take an array of bit-masked status bytes: char status[10]; Now, let's say we want to pull the 3rd bit out of each status byte and put them into an int, where the LSB of the int is status[0] bit 3, next is status[1] bit 3, etc. int foobits = 0; for( i = 0; i < 10; i++ ) { foobits ...

close votes
dumb question
 
@CatPlusPlus it's possible yes
 
Dropbox is not good for versioning.
 
@ThePhD version control is usually a lot more powerful than that
 
Learn git or Mercurial.
There are other ones, but only hipsters use them.
 

« first day (711 days earlier)      last day (4242 days later) »