« first day (230 days earlier)      last day (4733 days later) » 
01:00 - 17:0017:00 - 00:00

1:02 AM
@Xaade I use KeePass. It "types" the password with a combination of clipboard and simulated keypresses. Like everything, it's not 100% secure but it works well against keyloggers.
2
 
@Xeo : Did you set this topic?
 
hi
 
1:35 AM
hola
 
distract me from how sick I am
and how my screen hates me
 
:-[
everyone at work is sick, miraculously I'm not yet
 
kek
I've been sick for so long
 
 
2 hours later…
3:38 AM
hello
 
 
2 hours later…
5:37 AM
morning
I'm trying to do full-on const-nazi, but this looks sort of ridiculous: const byte * const * const bufferAsPointers =
@ID_AA_Carmack I've often wondered if const-ness should be the default and removed with a mutable keyword instead.
hummm background compatibility ftw! :D
 
5:52 AM
uck
 
Xeo
6:03 AM
@ildjarn Yes.
 
6:34 AM
Wha?
 
Xeo
7:01 AM
If anyone with enough rep is bored, vote for a close here
 
Xeo
7:21 AM
0
Q: Is `new (this) MyClass();` undefined behaviour after directly calling the destructor?

XeoIn this question of mine, @DeadMG says that reinitializing a class through the this pointer is undefined behaviour. Is there any mentioning thereof in the standard somewhere? Example: #include <iostream> class X{ int _i; public: X() : _i(0) { std::cout << "X()\n"; } X(int i...

 
morning all
 
Xeo
mornin'
Hm, I'm really on a run with [undefined-behaviour]-tagged questions lately
 
@Xeo, don't delete comments when I'm answering them :-)
 
@Xeo just make sure you yourself don't start displaying UB too :P
 
Xeo
@AProgrammer Heh, @sharptooth answered it in his edit. Sorry 'bout that. :)
 
7:33 AM
@Xeo no arm was done, I just deleted my comment as well.
 
Xeo
@AProgrammer But your point with inheritence doesn't only hold in the multiple inheritence case. See this.
 
@Xeo That's UB if you don't have guarantees that this is properly aligned for a Base. No idea if the standard makes such guarantees
 
@Xeo, You don't reconstruct an object of the same dynamic type as the deleted one, that is obviously wrong.
 
Xeo
@AProgrammer Yep, and it's very easy to do that
 
@Xeo, nobody said the structure wasn't very fragile, but I don't think it is an UB per itself.
 
Xeo
7:42 AM
@LucDanton Hmm, the alignment can easily be fucked up by mutliple inheritance
 
@Xeo Even in the case of single inheritance I'm not aware of a guarantee from the standard
 
@LucDanton Alignment is not very well characterized in the standard, but I don't see how this in a member of Base could not be correctly aligned for a Base -- at worse it is more constrained.
 
Of course you can rely on your implementation but that's different
@AProgrammer Implementations are free to be pathologically evil
 
@Luc, during the execution of a member of Base, this is a pointer to a Base. I don't see how it could be not correctly aligned for a Base.
I do see how reinterprect_casting a pointer to Derived as a pointer to Base can be problematic, but here all adjustments have already been done during the call.
 
That's a good point
(I'd phrase more as 'this is pointing to a Base' though, the type alone doesn't guarantee alignment)
So ideone.com/P4SFP is fine (modulo the use of this instead of a copy of it for placement new); it selectively recreates the Base subobject even in the face of multiple inheritance
 
8:22 AM
hello
 
8:40 AM
Hello
 
way too short, hmm should be able to generate at least 70 pages of BS
Some of things there are wayyy to obvious. "The electrical engineering solution to DHCP is defined not only by the construction of SMPs, but also by the technical need for massive multiplayer online role-playing games."
 
Not to mention the log graph that I got, with the 'Complexity (# CPUs)' axis ranging from -50000 to somewhere in the 1e10^6
 
Well they still got one of their papers accepted for some conference :)
 
lol, that is funny
 
9:02 AM
hehe :)
 
randam white paper generation
 
randam!
 
stochastic
 
stacastac!
 
Wish I had this sooner, I bet I could have passed some assignments using this generator.
:D
 
2
Q: Solving equation. Counting (x,y).

DmitriI'm having a trouble with my math: Assume that we have a function: F(x,y) = P; And my question is: what would be the most efficient way of counting up suitable (x,y) plots for this function ? It means that I don't need the coordinates themself, but I need a number of them. P is in a range: [0 ; ...

 
wolframalpha.com/input/?i=x*y+-+%28%28x%2By%29%2F2%29+%2B+1
grr
copy pasta
 
lovely
 
@MartinhoFernandes hmmm never been that good at math
 
9:10 AM
I like how Wolfram|Alpha queries get Perlifyied beyond recognition with URL encoding.
 
hahaha
I guess writing something that solves all (x,y) for P would be quite a challenge
cause the only way I can think of doing it, is by actually going ahead and solving the equation.... not sure if there is any other ways
 
there is one good comment there by Steve
essentially removed one of the variables
 
do you know what time it is?
Coffee Time!
 
oh I don't know what time it is where you are, but here it's almost lunch time
 
9:23 AM
It's 9:21
 
9:40 AM
COFFEE!!
 
Xeo
I'm hungry. :<
 
me too actually
hmmm, food!! :P
 
cooooffeeeee
I got me a low fat non dairy soy caramel latte with little foam
 
@LucDanton I don't think so. You need to reconstruct an object of the same most derived type or you risk having a bad vptr, see: ideone.com/m0rkb You probably can make it crash with a virtual call to a virtual function first introduced in Derived.
 
9:47 AM
@ÓlafurWaage latte??? ewwww
 
@AProgrammer I assume there is a requirement by the standard on the lifetime of subojects perhaps then? Can't be destroyed before the most derived type?
 
@TonyTheTiger btw I just got coffee, just so you don't think I'm completely crazy.
123 rep today and it's not even 10am
 
10:10 AM
0
Q: When to Thread. When not to Thread

musselwhizzleI'm new to the idea of Threading, but not asynchronous behavior. My Android app is taking ~180 millisecond to start up and ~550 milli when I use GoogleAnalytics trackViewPage method and MobFoxView constructor. Coming from Actionscript 3, anything that "took time" was automatically async and I was...

> It seems I'M responsible for deciding when something should be asynchronous.
How insane is that?
 
10:27 AM
lol I love how the silverlight/.net developers whine about Win 8 using html 5
 
@ÓlafurWaage oh ok
@Nils what's the problem with that? I thought HTML 5 was a good thing?
 
@TonyTheTiger but what with my investment in WPF / Silverlight?! cryyy :D
 
@Nils I think I'm missing something? What's WPF got to do with ?
 
Well obviously they would prefer WPF as the flagship technology for Win 8 instead of html 5
and now they have to relearn
 
I'll wait until September to see how true is that "have to relearn" part.
I doubt HTML5 will be the only option. It may be the one with the most publicity (it's the new one!), but the only one?
 
10:55 AM
@Nils oh I get it
I'm sure WPF will still be supported and used very much
 
@TonyTheTiger It won't be any more the latest and greatest so they'll have to relearn.
Or their resume is loosing value.
 
oh gosh
Hello @Als
 
> Update 5/23: The followup interview has been scheduled, and will be shot next Thursday, June 2.
Yay, new video should be up in a couple of days!
 
11:11 AM
@FredOverflow yay!!! :) Looking forward to watching that :)
 
What is your favorite c9 video?
 
not sure, there's a lot that I like
 
i liked watching the functional/haskell videos they have there
though I didnt know much about haskell
 
I found it rather mathematical...
 
@ÓlafurWaage Don't fear the Monad
2
 
11:24 AM
:)
 
Xeo
...
I crashed the Visual Studio compiler -.-
 
I like Haskell. And sometimes I miss the Maybe monad in other languages.
 
Xeo
> fatal error C1001: An internal error has occurred in the compiler.
 
@MartinhoFernandes Scala has Option[T] :)
 
@FredOverflow does that explain for a monad noob like me?
 
11:25 AM
@TonyTheTiger Why don't you try and watch.
 
@FredOverflow hmmm
 
Brian is great.
 
> I'm gonna explain Monads in terms of things you already know, I promise!
 
Yeah, that's also great.
 
11:27 AM
@FredOverflow And C++ has boost::optional, but what I miss is the ability to use do-notation with it.
Can I do something similar in Scala?
 
@MartinhoFernandes You don't need the do notation in Scala, because Scala has imperative control flow :)
But I'm sure I just misunderstood you?
 
Ok, I'm having trouble expressing myself.
I like the automatic propagation semantics of Nothing.
 
Ah. I don't know enough Scala to answer that question.
But I'm pretty sure I saw example Scala code that did something like that.
 
In C# I twisted the LINQ syntax to do that, but I think most people will not be happy if I use it in their code :)
var result = from a in SomethingThatReturnsMaybe()
    from b in SomethingElseThatReturnsMaybe(a)
    from c in YetAnotherMaybeishMethod(b)
    select NonMaybeishMethod(c);
 
Xeo
Ha, funny. MSVC's compiler simply crashes on my code. GCC gives me a nice diagnostic that I'm an idiot for trying to access a member function of a function pointer. :)
 
11:32 AM
> Because of how for comprehension works, if None is returned from request.getParameter, the entire expression results in None. This allows for sophisticated chaining of Option values without having to check for the existence of a value.
@MartinhoFernandes That's what you asked for, right?
 
Als
Hey @TonyTheTiger, hows u?
 
@FredOverflow Exactly.
Without that, it's not really a monad, just a type for optional values.
 
11:47 AM
en.wikipedia.org/wiki/Barton%E2%80%93Nackman_trick Having understood how to use this I ask myself why exactly it is allowed. I guess because templates are resolved at a completely different stage of compilation than inheritance..
 
Can you be more specific?
The Wikipedia article already explains how this is powered by ADL.
 
When I first saw it I asked myself why it acctually works
 
@Als I iz very well, what aboutz you?
 
ah haven't read the article yet shame was just too lazy to post my own example
 
Somehow related post:
6
Q: How do boost operators work?

FredOverflowboost::operators automatically defines operators like + based on manual implementations like += which is very useful. To generate those operators for T, one inherits from boost::operators<T> as shown by the boost example: class MyInt : boost::operators<MyInt> I am familiar with the ...

 
12:07 PM
greetings covets coffie mug
 
Als
@TonyTheTiger: I is bored....still an hour to get off work..
 
@Als you're bored at work>
??
I thought one worked at work, and boredom wasn't part of that, lol
 
Als
@TonyTheTiger: I finished my planned work for today now killing time..
 
@Als lulz
read something that you are interested in
 
Als
@TonyTheTiger: Why do you think I am on SO now then? :P
 
12:16 PM
@Als oh I see :)
 
Oink.
 
Go back in time and kill Hitler as a baby. He'd be so freaked out that a baby is trying to murder him, you'll have the element of surprise.
 
Als
0
Q: Given filesystem pathname, how to retrieve corresponding ABSOLUTE ITEMIDLIST?

user759588Looks like it can be done in one call or two, but which functions i have/must/should to use for that? I'm looking for best-practice approach, eg: API specially designed for path -> idl translation.

SO is turning in to a interface finder?
 
12:19 PM
@Johnsyweb I know that. :P
 
@CatPlusPlus Good-oh :-)
 
Lol, someone emailed me a Python question.
Where do people get those ideas from.
 
Als
Emailed?
 
@FredOverflow Well to me it's still not exactly clear (also looking at 3.4.2 from the standard)
So if item1 == item2 is processed by the compiler it looks at the classes inherited and also at friend functions (why friend? couldn't the operators just be protected?), but when is the templated class instantiated?
 
@CatPlusPlus lol, why does someone email you a Python question?? and is it a good question?
 
12:32 PM
@TonyTheTiger I have no idea what it says. I think I'll just go ahead and ignore it.
Because today I'm a mean, mean scratching machine.
 
what is this error:

Unhandled exception at 0x0086978c in init.exe: 0xC0000005: Access violation reading location 0x00000100.
 
A segfault on Windows I guess..
 
aghhh.
 
Xeo
@cyberrog Your exe?
 
12:48 PM
Obvious NULL pointer.
 
@CatPlusPlus lulz
@cyberrog just says it cannot access what's at mem address 0x00000100. Most likely caused by accessing a null ptr as said before or a pointer that points to an invalid object
 
If it were NULL, the location would be 0x00000000.
 
@CatPlusPlus good point I guess... so it's pointing to an invalid object or memory address
 
Xeo
It is most likely a null ptr, that accesses a member at offset 256 (or 0x0100 or 100h)
 
What Xeo says.
 
 
1 hour later…
2:22 PM
@Nils When the compiler sees class Foo : Base<Foo>, the template class Base<Foo> is instantiated. At this point in time, the type Foo is incomplete, so you can only do certain things with it.
For example, you cannot have a member of type Foo in the class template. (Which is a good thing, since it would lead to infinite recursion.)
@cyberrog This error means that your girlfriend might be pregnant.
@CatPlusPlus NULL is not mandated to be 0x00000000, although on Windows it probably is.
 
> (Although that's a QoI issue, not a requirement.)
What's QoI issue?
 
@TonyTheTiger If you say "lol hmm lulz" three times in front of a mirror, Johannes Schaub appears in your bathroom.
@MartinhoFernandes Quality of Implementation
 
@fred thx
 
Anyone here use MSVC 2008?
 
2:38 PM
@JohnDibling Yes
 
Can you get the $TID psudo variable to work? msdn.microsoft.com/en-us/library/ms164891(v=VS.90).aspx
 
@JohnDibling Yes, $TID gives me 4012 here.
 
hmmm
I get "Error: symbol 'TID' not found
But other psudo variables work
 
You understand that $TID has to be entered into the watch window? You cannot use $TID in source code, if that's what you want to do.
 
I'm also having some very funky threading problems. Related, I wonder?
 
2:42 PM
I have yet to encounter a threading problem that isn't funky...
3
 
No, I'm entering them in tot he watch window. As I said, other psudo variables work.
Guess I'll reboot. :~
 
And you sure you spelled that right? T I D?
 
Yeah,. I even copy-pasted from the MSDN site to double check
 
Because I would probably misspell TID as TIT the first couple of times ;)
 
2:45 PM
lol
 
What exactly are the funky threading problems?
@JohnDibling Do you see the thread ID when you debug the program? See the following screenshot:
 
@FredOverflow I haven't seen a Windows compiler that wouldn't define NULL as 0. Hell, I haven't seen any compiler that wouldn't define NULL as 0. But then again, I only care about x86-based platforms.
 
@CatPlusPlus In C++, NULL is defined as 0, but that does not mean the underlying address has to be 0 :-) Stroustrup discusses that in detail in "The Design And Evolution of C++", IIRC.
 
3:03 PM
@Fred: Let me test it again now that I've rebooted.
But yes, I'm able to see the thread IDs elsewhere. Its just the psudovariable that doesnt work.
 
3:19 PM
@TonyTheTiger One can work at work and still be bored.
@FredOverflow Header info to the object? Tries to access object which is actually at ptr+offset
 
@FredOverflow: is that definition of NULL inherited from C? Or can NULL really be non-zero in C?
 
@FredOverflow Bloody Mary!!!
 
@FredOverflow hahah
@Xaade o rly?
 
@awoodland In C, NULL is usually defined as ((void*)0). In C++, it is 0. But this has nothing to with with the representation of the null pointer, it could be any address (as long as that is not also the representation of a non-null pointer, of course).
@Xaade What?
 
@FredOverflow Why would a null ptr look for an object at address 0x00000100, because the object is expected to have header info?
 
3:29 PM
@Xaade I still have absolutely no idea what you're talking about.
 
class CMyObject { int x; };

CMyObject* x = NULL;
CMyObject* y = new CMyObject(x);

memory exception at address 0x00000100
 
...okay...
 
x->mymember;
 
undefined behavior
 
might not be 0 depending on what CMyObject has in it
(back to the earlier why is it 0x100)
 
3:32 PM
x isn't at address 0x00000100 unless there's more data to an object than its contents
 
Look, on a 32 bit architecture, there are (potentially) 2^32 valid addresses. If you want to have nullability-semantics, you have to map one of those addresses to null. It does not matter which one of the 2^32 addresses you pick. It just so happens that on many platforms, the first available address was chosen, but 0xffffffff (or any other address) would have worked just as fine.
On a related note, many programmers chose -1 as the "null value" for integers when it fits their logic.
 
@Xaade x->mymember might be implemented as something like (pseudo-code): *(member_type*)( ((char*)x)+offset_to_member))
so if x is 0 and offset_to_member is 0x100 guess what part of the memory is being accessed (only one try allowed)?
 
@CatPlusPlus That's not the right question....
 
3:43 PM
@Xaade That's the answer to everything.
 
No.... "The meaning of life, the universe, and everything"
If you answered the question, what's not the answer to the meaning of life, the universe, and everything.... you'd might (with a low probability) be teleported into anti-verse if you said 42.
No heaven, no hell, do not pass go, do not collect $200
@Xeo so close to 10k and you offer a 100 bounty?!?
 
@CatPlusPlus No. It's the answer to "the Ultimate Question of Life, the Universe, and Everything".
42 being the answer to everything, or the meaning of life is just silly.
 
is it me or is reddit addictive?
 
@TonyTheTiger not as bad as bash.org
 
Rhinorrhea or rhinorrhoea, commonly referred to as runny nose, consists of a significant amount of nasal fluid. It is a symptom of the common cold and of allergies (hay fever). The term is a combination of the Greek words "rhinos" meaning "of the nose" and "-rrhea" meaning "discharge or flow". Rhinorrhea can also be a sign of withdrawal, such as from opioids (especially methadone). Symptoms display circadian rhythms. Overview Rhinorrhea is a frequently encountered condition that is usually not dangerous. The discharge may be colored or thick as a result of conditions such as sinusitis. ...
 
3:53 PM
@TonyTheTiger What I get from this? rhinoceros is a fish with a big nose.
 
Xeo
@Xaade I even offered a 200 bounty the week before on my type erasure techniques question, I had 8.6k or sth.
 
@Xaade lol
 
Overview Rhinorrhea is a frequently encountered condition that is usually not dangerous.
ZOMG nose running.... gonna die!!!!!!!!!!
 
Xeo
And before that a 50 rep bounty on the same question. Bounties are a good way to get some attention. @JohnDibling for example got hooked by the 50 rep bounty (or atleast noticed the question then) and wrote a nice little example which gave me some valuable insights. :) Rep is there to be used.
 
Rep is money for getting answers...
Xeo.... go ask some simple questions...
I have a plan
 
Xeo
3:56 PM
What? x
xD
 
wanna live here?
Tittybong is a locality in the northwest of Victoria, Australia, within the Shire of Gannawarra. Tittybong is west of Kerang and east of the Calder Highway. It is south of Swan Hill, the nearest large town. The town's name has raised eyebrows in the past, in the same notoriety of Fucking, Austria, Dildo, Newfoundland and Labrador, and Pussy, France. Tittybong Post Office opened on 1 January 1884 and closed in 1968. References
{{Infobox Settlement |name = Fucking |official_name = |other_name = |native_name = |native_name_lang = |nickname = |settlement_type =Village |total_type = |motto = |image_skyline = Fucking, Austria, street sign cropped.jpg |imagesize = |image_caption = The frequently stolen traffic sign, at the entrance to the village of Fucking. |image_flag = |flag_size = |image_seal = |seal_size = |image...
2
 
@TonyTheTiger I've used that phrase before
 
Xeo
@Xaade What plan? I'm scared.
 
@Xaade lol
 
@Xeo Get a high rep person to post a question and put a bounty on it. I'll answer another easy to answer question. You edit the question.
 
3:59 PM
are there any guarantees about when a stream is flushed?
 
MWA HA HA
 
@MartinhoFernandes :P
 
Xeo
@Xaade Edit in what way?
 
@wilhelmtell It'd be logical for it to flush when closed, at least for streams that have close operation defined.
 
@CatPlusPlus but other than that?
 
Xeo
4:01 PM
@wilhelmtell When you call mystream.flush(); ? :)
 
Other than that, maybe if the buffer is getting too large.
 
@Xeo To match my answer.
 
I don't know if that's a guarantee, though.
 
Xeo
@Xaade lol
 
can an implementation flush at time other than when it must?
 
4:01 PM
Better to flush explicitly when you need it.
Flushing is potentially expensive, so I'd say it'd be better if it didn't.
 
"... thus Fucking means '(place of) Focko’s people.'"
Really not so sure that the translation is that much better.
Meet the Fockos
 
what's the booster library ?
 
ok, so does the standard say what size the stream buffer must be?
 
@CatPlusPlus Yes, but you can't keep buffers growing forever, so it will eventually be done implicitly.
Actually, you can keep buffers growing "as forever as possible", but you have to swap them out to disk, which is already hellishly slow (and outright stupid if it's a file stream), so...
 
@wilhelmtell std::cout is flushed when std::cin is used. See the tie member.
 
Xeo
4:05 PM
@MCCP boost.org
 
ok ok, what I'm asking is not when I can flush or when I should flush. I'm asking about when an implementation can flush. I'm not getting at performance, but at correctness.
 
It can flush whenever it wants.
 
Xeo
Hm, yay? I created some template trickery which allows me to write the following without any kind of dynamic memory allocation:
 
Here is a concrete example of what I'm asking.
 
Xeo
struct MyImpl;

class MyClass{
  MyImpl* _impl;
};
 
4:07 PM
Some implementations will try to minimize flushing for performance, others will avoid buffering altogether.
 
For what I understand, this program has undefined behaviour:
#include <fstream>

int main(int argc, char* argv[])
{
    std::ofstream a("f", std::ios::app);
    std::ofstream b("f", std::ios::app);
    a << 'a';
    b << 'b';
    return 0;
}
Well maybe UB is not the word, but you can't predict in what of (at least?) two ways it will behave, for what I understand.
 
@Xeo Using a 'small object' as arena? (as in small object optimization)
 
Xeo
@LucDanton well, kinda, but not really at the same time
I don't even need to know the size of the impl struct in the header
 
@MartinhoFernandes I said that earlier.
 
Xeo
MyClass::MyClass() : _impl(get_impl_buffer<MyImpl>()) {}
where get_impl_buffer returns a pointer to a buffer with the exact size of my impl struct.
 
4:12 PM
I woke up at 14 and I'm so damn sleepy. I don't get how that sleeping thing works at all.
 
Xeo
@CatPlusPlus Sleep doesn't work, it sleeps
 
@Xeo Is your solution small enough to fit e.g. on ideone? I'm curious
 
Xeo
@LucDanton Yeah, but it has a giant drawback. xD
The thing is, for each and every get_impl_buffer<T>, I return a unique buffer, up to an implementation defined maximum, at which point it loops
 
@wilhelmtell I think that's implementation-defined. But I'm not ready to dismiss UB.
On Windows I get a file with 'baba'.
 
@MartinhoFernandes really? well I'm not sure it's allowed to do that.
 
4:16 PM
Can't understand how.
 
I think you can get 'ab' or 'ba'
 
Ok, I figured out how. I had a bug in my printing code :(
 
oh lol
 
I got 'ba'.
 
yes, that's what i get with gcc 4.2.1 on os x
but i think it's not a guarantee
 
4:19 PM
If there's no buffering, you can get 'ab'.
 
i was experimenting on the implications of having to files open for append at the same time.
 
Or a buffer of size 1.
 
useful buffer size.
 
if a buffer size of 1 fills in a forest, does it make a ...
 
Damn... What is wrong with this: ideone.com/pHcNx?
 
4:21 PM
fills in a forest?
@awoodland burned down yesterday, when a couple of teens forgot to put out their campfire.
 
Please don't tell me how stupid I am.
 
Darn... didn't see it.
 
@MartinhoFernandes that's the code that writes 'baba' ?
 
@wilhelmtell The one I posted. After you run it twice!
Duh.
 
Xeo
@Luc Ah noes. My nice little impl_buffer only works on MSVC because of broken two-phase lookup. :<
 
4:27 PM
Why do you write to "f.txt" and read from "f"?
 
@Xeo I'm sorry to hear that
 
That was a leftover from a previous version. I fixed it later.
 
Xeo
@LucDanton I think it still works with manually invoked ctor / dtor, but that doesn't look nice
 
:p but even if it were f.txt in both, you append :p
 
That's how stupid I was being.
It became obvious when it printed 'bababa'.
 
4:30 PM
but yeah, it all just reminded me of flush(). I rarely if ever used it, and now it's clear that having two ofstream objects open for append into the same file at the same time is one time when you (might) want to disable bufferring.
 
Xeo
@LucDanton Ahaha, nope, was my stupidity. :) In MSVC, I had both the forward declare and the definition of the impl in a detail namespace, and in Ideone I only removed that from the forward declare.
The technique I used in there, function pointer as holder of template type state, is from something I saw in the type erasure code @JohnDibling wrote for me. :)
 
@Xeo Did you test it on a header/source setup? I notice you have the default constructor and the destructor for Test commented out here
 
Xeo
@LucDanton You don't need them, because impl_buffer is automatically default initialized
 
@Xeo You need them because if the compiler generates the implicit ones they'll have an incomplete Impl
so putting them in a source where Impl is complete fixes that
 
Xeo
@LucDanton The version above looks exactly like what the source would look like in a header/source setup after the preprocessor ran over it
 
4:43 PM
You need to do just that for the destructor of a type that has an auto_ptr to an incomplete type
 
Xeo
Lemme test again then
 
Well then what's the point if the definition of Impl is just sitting here :)
 
Xeo
@LucDanton The point is, that you can now completely abstract Impl from the outside, you only need to know the forward declaration. You don't even need to know the size for the buffer in the header.
 
Then this is not what the preprocessed source would look like since the definition of Impl is sitting right here!
 
Xeo
@LucDanton But it's below the template instantiation for impl_buffer!
wait, what?
> error C2660: 'operator new' : function does not take 2 arguments
 
4:48 PM
#include <new>
 
Xeo
d'oh
@Luc Okay, I'm sorry, you were right. :( need explicit definition of ctor/dtor
 
@Xeo You do understand why though?
 
Xeo
@LucDanton Yeah.
Compiler generated ctor/dtor will be inline defined in the header, and there the impl isn't known yet.
 
Then that's fine
 
Xeo
So, what do you think of the code? :)
 
4:53 PM
Out of curiosity did you have a particular scenario in mind? I'm surprised by the circular buffer situation.
 
Xeo
@LucDanton The circular buffer is just there so i won't have an infinite recursion. :/
 
Myself I've been meaning to write a small_object template. Not quite similar in use (it's not for incomplete types) though.
 
Xeo
@LucDanton Yeah, this one was really only because I saw a question about pImpl, and someone commented he uses a hand-sized buffer in the class instead of dynamic allocation. The problem with that is the alignment that you don't know of
So it was specifically designed for this
 
It's not similar though because all the buffer templates get instantiated as soon as one object is used
 
Xeo
And I wanted a scenario where I can try out the function pointer as a holder of the type information
 
4:57 PM
so it's more of a circular buffer of statically allocated memory
 
Xeo
43 mins ago, by Xeo
@LucDanton Yeah, but it has a giant drawback. xD
:)
 
I meant to underline the fact that all the memory is there, not the circular bit
 
Xeo
Yes, that's what I consider the biggest draw back
 
with the buffer member solution there's only as much memory taken as there are objects alive
 
Xeo
it code-bloats quite a bit
 
4:58 PM
Oh okay
 
Xeo
@LucDanton What I meant on this one was the "all the buffer templates get instantiated as soon as one object is used"
 
We're on the same line here
 
Xeo
Still, I had fun coding it. Was a nice puzzle. :)
 
01:00 - 17:0017:00 - 00:00

« first day (230 days earlier)      last day (4733 days later) »