« first day (1012 days earlier)      last day (3940 days later) » 

12:00 PM
I have enumerators urgent and not_urgent, but I can't think of a fitting enum name.
 
Xeo
urgency
And I'd rename the enumerators to high and low
 
Ok.
Ah.
 
Xeo
And of course use a scoped enum :P
 
use priority, more professional, like the prority queue :p
 
enum class urgency { who_cares, omg_i_am_dying };
 
12:02 PM
urghtdfkjadsfk;ajfadfa
 
Actually, the enumerators indicate whether or not a TCP ack must be send immediately or may be delayed. So maybe I should name it Delayable with enumerators yes and no.
 
Xeo
Sounds like a bool.
 
@Xeo Screw bools.
 
I have a bool right now :D
 
Xeo
@R.MartinhoFernandes Yeah
 
12:03 PM
Named bools are so much better.
 
But bools are really weakly typed enums.
 
Xeo
Sure
 
smells like priority queue ...
 
f(true, false, true, false, false, false, true);
 
Xeo
But I don't quite like the DescriptiveName::Yes/No form
@StackedCrooked enum class reply{ immediate, delayed };, maybe?
 
12:05 PM
if it is TCP then it has to be acked ... but since there are messages with higher priority, the rest of the acks can be delayed
 
I am doing something extremely wrong
 
Xeo
Sounds like @ThePhD
 
@Xeo I take note.
@BartekBanachewicz Maybe it will underflow into right.
 
@BartekBanachewicz Famous last words.
 
@Xeo except I am doing it for something that makes sense
 
Xeo
12:06 PM
@R.MartinhoFernandes Nonono, "IT WORKS!"
 
@BartekBanachewicz that's what thePHd would say
 
@BartekBanachewicz yeah right :D
 
@melak47 well, yeah.
 
followed by "oh wait, it doesn't"
 
@BartekBanachewicz what are you doing wrong then :)
 
12:08 PM
I wonder what the thePhd's pH is.
 
d
obviously
 
Xeo
0
Q: Modifying constant object

KolyunyaI was looking through the interview questions to a junior C++ developer position. The question is (quote): Is the following code correct? struct Foo { int i; void foo ( void ) const { Foo* pointer = const_cast<Foo*>(this); pointer->i = 0; } }; I would answe...

I expected something stupid from the title.
 
Xeo
I was pleasantly surprised to be wrong.
 
@melak47 I am declaring template template parameter wrong
 
12:10 PM
you must be a happy person a lot of the times
 
I mean, vector now fits.
 
Xeo
wtf are you doing
 
template<class T, class Alloc = std::allocator<T> > class Cont,
 
Oh boy, no.
 
@Xeo I have to somehow get Container and Elem types, right?
 
Xeo
12:12 PM
what for?
 
@Xeo to check Elem for POD-ness and Container for contiguousness
 
Xeo
The latter is done through the trait I posted
The former would be std::is_pod<ValueType<Cont>>
 
what's ValueType?
 
Xeo
Something that takes Cont::value_type if it exists, and is specialized for C-style arrays
Btw, I'm really starting to dislike all this stupid special handling for C-style arrays :|
 
12:14 PM
Btw, std::vector<bool>. Just being an ass.
 
Xeo
heh
 
@R.MartinhoFernandes I should explicitly disable that
 
Xeo
It's still contiguous, no? :P
 
@BartekBanachewicz I honestly never give a fuck about it.
 
std::vector<*void>
 
12:14 PM
@Xeo No.
 
Xeo
They even broke that?
 
@Xeo It's not a contiguous sequence of bools.
 
that's the point
 
arguably, the storage in a vector<bool> is contiguous.
but you can't access it as an array of bools.
 
Xeo
@DeadMG That's what I meant.
 
12:15 PM
because it's not.
 
@Xeo I am starting to dislike things like that not being in std
 
so whilst technically, it is in fact contiguously stored in memory, you can't treat it like it's a contiguous sequence.
 
@Xeo Let's put it this way: std::vector<bool>::iterator is not a contiguous iterator.
 
Xeo
template<class Alloc> struct is_contiguous_range<std::vector<bool, Alloc>> : std::false_type{}; // problem solved!
 
@Xeo In this case, I would not do that.
What is the common code that your function will have?
 
12:18 PM
Variadics make template template parameters a little more useful I think.
 
(Gist of my opinion is: you don't want to be that generic; you want pointers and only pointers all over)
 
@R.MartinhoFernandes ...
 
@BartekBanachewicz What's the implementation of data look like?
You mentioned before that the code will be the same.
 
@R.MartinhoFernandes gl::NamedBufferData(..., c.data(), c.size() * sizeof(Elem))
 
Xeo
@R.MartinhoFernandes True, pointers actually give a nice "contiguous range" concept.
 
12:22 PM
inb4 ragestorm on pointers incoming
 
POINTERS! AARG..
 
@Xeo Pointers are the concept.
@BartekBanachewicz Except that won't work for C-arrays.
 
Xeo
gl::NamedBufferData(..., first, (last - first) * sizeof(T));
With data(T* first, T* last) or something
 
@R.MartinhoFernandes std::data() and std::size()?
 
Xeo
@BartekBanachewicz nope
 
12:23 PM
@Xeo why?
 
Xeo
Because.
 
I want data(v); call.
because that's how it's supposed to look.
 
lol what is std::data(); supposed to return.
data?
 
T::data() or specialized for C arrays
 
@BartekBanachewicz You need to treat arrays specially for that.
Or...
 
12:24 PM
Or.
 
Xeo
10 mins ago, by Xeo
Btw, I'm really starting to dislike all this stupid special handling for C-style arrays :|
 
std::addressof(*std::begin(x))
 
wait there's no std::data()?
 
Xeo
1 min ago, by Xeo
@BartekBanachewicz nope
 
for fucks sake.
 
Xeo
12:25 PM
There are two containers with that member.
 
@R.MartinhoFernandes I can live with that.
 
@Xeo A range [first, last) is contiguous if it is the same as the range [std::addressof(*first), std::addressof(*last)).
 
string and vector?
 
Xeo
@FlorisVelleman Three, then.
I always forget std::string as a container.
 
The property that "contiguous" gives is that you can iterate on the original iterators or on addressof(*it).
 
12:26 PM
@R.MartinhoFernandes true.
 
Except you're still fucked.
Meh.
 
Xeo
@R.MartinhoFernandes cue adl_begin(x) :P
 
Can't dereference end.
Just specialise it.
Or make array_ref.
 
anyway main.cpp:30:84: error: expected a type, got ‘detail::value_type<T>::type’
my value_type sucks
 
@BartekBanachewicz typename
 
Xeo
12:28 PM
@R.MartinhoFernandes Where specifically?
 
template<class T> struct value_type { typedef typename T::value_type type; };
template<class T, size_t N> struct value_type<T[N]> { typedef T type; };
@R.MartinhoFernandes nope, I am not that lame, I guess.
 
@Xeo Where's the end of std::addressof(*std::begin(x))?
 
Xeo
ew, okay
 
ITT C arrays suck
 
Oh, well, std::addressof(*std::begin(x)) + (std::end(x) - std::begin(x)).
 
Xeo
12:28 PM
mh
 
Dammit, why do I keep solving this.
 
Xeo
std::distance
 
@R.MartinhoFernandes because it's a nice problem that I actually need to solve
 
Xeo
or not
 
@Xeo No, you want them to be RA; better to require more upfront.
 
Xeo
12:29 PM
hm
 
so what's wrong with my value_type?
 
@BartekBanachewicz Problem seems to come from usage, not definition.
 
class = typename std::enable_if<
                                std::is_pod<
                                            detail::value_type<Container>::type>::value
                                                                                       >::value>
 
fffffff.
 
Xeo
12:30 PM
2 mins ago, by Bartek Banachewicz
@R.MartinhoFernandes nope, I am not that lame, I guess.
Mhmmmmm
 
totally.
I can't C++.
 
Xeo
Guess why I wrote ValueType<Cont>
Oh, and I just remembered boost::range_value<Cont>
 
that's an Invoke?
@Xeo you're kidding me right?
 
So, I'd go with data(x) { return addressof(*begin(x)); } and size(x) { return end(x) - begin(x); }.
 
Xeo
@BartekBanachewicz template<class T> using ValueType = Invoke<value_type<T>>;, yeah
 
12:33 PM
@Xeo ah, of course that won't work in MSVS
 
@Xeo Had to reinvent it because not SFINAEish :/
 
@R.MartinhoFernandes okay.
 
Xeo
@R.MartinhoFernandes :/
@R.MartinhoFernandes Not that Bartek's value_type is SFINAE-friendly.
 
@melak47 What do I do
 
@ThePhD to do what?
 
12:35 PM
with the D2D1Device and stuff like that?
 
oh. well basically, you need those stupid devices and contexts and factories
 
@melak47 :)
 
and then you create a D2D render target for a D3D texture
and draw to that.
or, like kbok did, you can draw directly to the window, apparently
 
GDI+. :D
Or, uh, I think D2D allows you to draw directly to the window I think..
... I THINK.
 
@ThePhD yeah, you can create a render target for the hwnd
 
12:37 PM
Still, I'm contemplating separating it out into a separate service (GraphicsDevice2D) or just having both 2ddevicecontext and 2ddevice on the GraphicsDevice class itself.
 
Ugh, I hate it when people talk about an "universal" memoization function and provide one that sucks for recursive functions.
 
It sounds like it would be better to have it as a GraphicsDevice2D, and expose all of the capabilities there in.
 
@R.MartinhoFernandes I've decltyped the returns, but it cannot find the proper data(x) to call, apparently
yaay
0x234e010 0x234e01c 0x7fff9aaa9fb0 0x7fff9aaa9fbc
I think it's working!
let's try C array (uh-oh)
heh nope.
 
TextDevice... TextEngine... ?
 
@ThePhD the question is...do you want to do that
 
12:43 PM
Maybe GraphicsDevice2D should have the Direct Write engine.
@melak47 Sure. I don't see any reason to draw directly to the hwnd (unless you're told otherwise?)
 
@ThePhD Context2D :3
 
uh oh, time for MSVS test
@ThePhD he meant you should draw to D3D texture, I think
that makes sense (for postprocessing)
 
drawing to a window is...icky :E
 
Draw to paper.
 
Not everything uses post-processing, so I think I should default to drawing to the hwnd until you do something like SetRenderTarget2D.
 
12:45 PM
D3D2printer
 
@ThePhD I found it cleaner to always draw to a texture and composite them.
 
here is my amazing creation @R.MartinhoFernandes @Xeo
 
@R.MartinhoFernandes You'd be the envy of middle-roll dice builds everywhere.
 
@ThePhD assume everything does.
 
@ThePhD Of what?
 
12:45 PM
@melak47 Do you always have to call BeginDraw on the D2D device?
@R.MartinhoFernandes Erm.... nevermind.
 
Xeo
@BartekBanachewicz One of c and d is redundant. :P
 
@BartekBanachewicz Oh, btw, that data incidentally SFINAEs away on vector<bool> (side-effect of not using its lying typedefs and using the addressof directly)
 
@R.MartinhoFernandes I've added an explicit check anyway
 
@BartekBanachewicz No need.
 
I could produce pretty static_assert message on it, I guess.
 
user142019
12:48 PM
lol std::vector<bool>.
 
Xeo
@BartekBanachewicz The lost ::types would like a word with you.
 
@BartekBanachewicz Just forget about it. No one should use it.
@Xeo lol
 
user784668
@R.MartinhoFernandes of course, because nobody should ever use C++
 
@melak47 Do you know if you can interleave D3D calls with D2D calls?
 
@Xeo hmm? of enable_if?
 
12:51 PM
@ThePhD I wouldn't
 
Xeo
@BartekBanachewicz ya
 
Like, can you draw some text with D3DText, draw a quad, and then draw some more text, and then the half-transparent quad covers the D3DText?
@melak47 You wouldn't? :c
 
@Xeo why does it compile then? :F
 
Xeo
Because.
 
@BartekBanachewicz Because the problem is that it will never fail.
 
12:52 PM
ouch
 
@ThePhD Pretty likely that internally, D2D batches calls to D3D.
 
@ThePhD hm, well, actually shouldn't matter. it should have it's own D3D device internally
@DeadMG not just likely, fact
 
Hm. Well, I guess I'll give it a try and see what happens...
 
@BartekBanachewicz Basically, std::enable_if<false, void> compiles fine. It's std::enable_if<false, void>::type that fails.
 
Hm. Times New Roman is guaranteed to be on Windows XP -> Windows 8 computers, right?
 
12:53 PM
@R.MartinhoFernandes funny enough, detail::size broke on std::list instead
 
Windows 98.
 
@ThePhD just use "" as a font, and it'll pick something :p
 
@BartekBanachewicz Oh sure, it will break for many other reasons, but never because of your enable_if checks.
 
oookay
added.
 
12:54 PM
@melak47 Works for me. :D
 
Let's compile Minicraft with it.
 
so you can draw some stuff with D2D, but you'd have to flush it.
 
D2D has two-dimensional error codes?
 
@DeadMG unless you EndDraw()
 
@R.MartinhoFernandes Apparently. Plus an error code. :D
 
12:55 PM
hm, how does D3D report errors?
You set up a callback?
 
is a "Is this a dumb way to do something" a valid question on SO?
 
@BartekBanachewicz HRESULT :D
 
@melak47 HRESULT of what
 
It fills your stderr / stdout with error messages, or returns an HRESULT on calls that can fail.
 
@ThePhD return value of stuff that can fail :3
 
12:56 PM
@melak47 Better to Flush if you're not done drawing.
 
@ThePhD what if I want my own stream?
@melak47 so you have to check every return value?
 
@BartekBanachewicz Shrug. Don't know.
 
@BartekBanachewicz Of the functions. It's COM.
 
somehow I doubt that the OGL API throws exceptions anyway
 
@BartekBanachewicz Just like you have to glGetError after every call. Yes.
 
12:57 PM
@BartekBanachewicz only on stuff that can fail :)
 
@DeadMG you register a callback OR check the error log manually /cc @R.MartinhoFernandes
@R.MartinhoFernandes um, that was ancient and terrible
 
D3D debug runtime has the error log too
 
@DeadMG now that's interesting. (and closer to what I was asking about)
 
Xeo
> And its may loss optimization the program.
 
@BartekBanachewicz Is debug_output core?
 
12:59 PM
@R.MartinhoFernandes yes
 
Since when?
 

« first day (1012 days earlier)      last day (3940 days later) »