« first day (979 days earlier)      last day (4195 days later) » 

06:13
@melak47 Why are you up so late anyhows?
only got up at around 6 pm, so I can't sleep :p
Mmm.
But what if you're late for your summer job?!
my what?
You don't have a summer job/internship/school dealie?
I'm not even on semester break yet
06:28
Ooh.
Your school extends this far into the summer? o.0
I still have stuff for 3-4 weeks
Ell
Ell
I have school for another 4 weeks
Can someone explain me, what does this mean? size_t size = (size_t)(1 + ((X*)0));
This gives a compile time error
are you using C or C++?
It should be on anything either C or C++
i was using gcc however
06:35
C is not C++
i mean sizeof is common to both C and C++
besides, as that answer clearly states, it is stupid limitation
can you answer my question please. If you compile this code it gives error as expected.
It may be, but I do not know C well enough to know if Cs version of sizeof behaves exactly like C++s sizeof
Tell me in terms of C++ in that case, do you think it works on g++?
i mean C++ version of gcc
06:37
simple answer is to just try it. But from reading the comments that looks to be abusing to compiler to simulate sizeof
humour here, why do you want to avoid just using sizeof?
It's an interview question i am preparing for
but it does not compile on C++ as well
give it a quick try on IDE one if you have doubts on my word
as the comments say, it is not well defined behaviour. The only ~safe~ way for this is sizeof. You can tell your 'interviewer' that is how you do it potentially, but follow up by saying that it is a terrible thing to do with no valid use case
that is a different thing, but can you tell me what that statement does? And how come the author claim, it works without using datatype for X?
X is the data type, but it using a pointer to said data type
do you think this will compile? int main()
{
size_t size = (size_t)(1 + ((X*)0));
}
int main()
{
size_t size = (size_t)(1 + ((X*)0));
}
06:45
it is casting the 'int' value '0' to an 'X pointer' to which it adds one to which it then casts to 'size_t'
if you write that it won't compile
try my code
it is basically 'forcing' an X to be at '0', then trying to increment that X* to the next 'X' object, getting the address of the next X, in theory this change in bytes should be how big a single X is, which is why it is caste to size_t
it might work if you compile it as C rather then C++
that is bad C code, and even worse C++ code
either way it won't compile C or C++
does '0' have special meaning to a pointer?
A better option might be to create an array X[2] get the address of [0] and [1], convert those address to size_t and then subtract one from the other
@Telkitty猫咪咪 no, it is just converting the int to and adress
it is possible the compiler is preventing you from doing such a thing, as it means you can could attempt to start use memory ANYWHERE in ram
but you are basically asking 'why does this really dodgy thing that no compiler has to support fail to compile'
06:50
it works in MSVC :p
not that that means anything
yeah, MSVC is a fly by night piece of crap :P
@thecoshman It compiles fine. Person does not know either language.
@LucDanton vOv I'm not too fussed about weather or not shitty code works
maybe they didn't substitute X for anything? :p
@melak47 oh god o_0 I hope he wasn't that stupid
06:51
@thecoshman I didn't say 'work'. However a compiler would be wrong to reject the snippet.
@king you did substitute 'X' for a type
@Luc Danton: Which code did you try and it compiled and which compiler? lol
@kingsmasher1 It doesn't matter. If you don't understand the snippet, or if you can't get it to compile, it's not of any use to you.
@LucDanton well, from a moral stand point it should with an error like "See this line ^ yeash, that one just up there? It is bad and you should feel bad!"
If you must 'prepare for an interview' start by learning the language, not the snippet.
06:53
@ThePhD I made a thing
@LucDanton: When you challenge other's understanding, you should have the mettle to prove it
@thecoshman Indeed. 'Not rejecting the snippet' still allows for the sending of strongly-worded letters!
@LucDanton: Else better to keep shut than sending obnoxious comments
@king bad move buddy
oh snap, did he just tell Luc to shut it?
06:55
We are offering help, do not get all smart arse about it
@melak47 Oh?
So, with polymorphic lambdas, I wonder if we might see this start happening more often:

auto foo = [](const auto &a, const auto &b) {
...
};

int main() {
...
}
@ThePhD for input layouts
@thecoshman It's the standard attempt at 'I know, I'll taunt them, they'll get me all the answers when they'll feel the need to assert how much they know'.
06:55
Lol. You're a million years behind. :P
@thecoshman: I am not denying that, but people should mind their words. I am referring to "Luc's" comment
@kingsmasher1 me too
any way, time to earn my bread and butter
@ThePhD does your's have typed shader semantics? :3
@melak47 It has that, and more.
@ThePhD like what? :D
Ell
Ell
07:04
Typed shader semantics? What is tthat? Is hsls not strongly typed?
@Ell well, yeah
I think
but on the C++ side
you specify semantics with strings :E
Ell
Ell
So, your shaders that are in-source are type checked before the program compiles?
@Ell Are you familiar with Embedded Domain-Specific Languages?
Xeo
Xeo
Morning
@Ell nah :p
Ell
Ell
07:08
Not very - would I be correct in saying boost::spirit is such thing?
I just defined an enum of valid standard semantics so you can't use a wrong one accidentally.
@thecoshman Sorry man. Great timing for the connection to shut off just as I had a solution. Using an unreliable wireless connection now. Anyway, here is my solution (though it may not be the best one, at least it works). :)
Xeo
Xeo
@Ell Ya
@Ell Yes, in a fashion.
Xeo
Xeo
07:11
@MarkGarcia Ew!
spam detection? for viewing a pastebin? whut
@Xeo "At least it works." :P
Lol
Anyway, I'm not staying for long. Have to work out this problem with our ISP.
@melak47 Hokay, spam filter gone, It should be viewable.
Not sure why it flagged my thing as spam. o.0
07:16
@thecoshman It should be better to have the placeholder (in place of _1) get the address of the passed argument to be passed to the target function (i.e. get_address(_1)). I think I've attempted do have something like that before, though I still don't have enough TMP experience and skills at that time.
@ThePhD or why I have to enter a captcha to view spam o.O
Xeo
Xeo
23 hours ago, by Xeo
std::bind(bar, std::bind([]std::addressof, _1)); :D
Of course, since []foo doesn't exist in standard C++ (yet), you have to write such a functor yourself.
@Xeo What's that []foo? A "create lambda from this func" feature?
Xeo
Xeo
Basically.
Xeo
Xeo
07:19
Think of it as "pass-by-name"
@Xeo How is it formally called?
Xeo
Xeo
Whatever I want to call it :)
atm, I call it a "lifting-lambda"
@Xeo Hmm... Does it mostly inter-operate with std::bind?
Xeo
Xeo
It creates a normal functor.
So pass it whereever you want.
@MarkGarcia let's have a lookskie then
07:27
@thecoshman You can't use placeholders like so.
@thecoshman I know... it's somehow a yuckie. :P
yeah... well, the solution I came up with in the end, and I am still not too keen on it, is this
Why the $#$@ can't the :: scope resolution qualifier be applied to reference-to-class type?
I'm sick of writing remove_reference.
Aliases!
problem is, when using this, you have to declare the type in your class as Glid<decltype(&glDelete)> glid and then in the constructor create it as glid(&glDelete) or glid(&glDelete, /* id value */)
@LucDanton where?
07:30
The suggested get_address(_1).
I think I would also like a 'default' template destructor if the delete function you pas is not of the right format so that I can static_assert if you use the wrong format
What's the advantage of the [] overloaded_name syntax over & overloaded_name?
@Potatoswatter Latter requires disambiguation and isn't polymorphic.
@thecoshman handle ~
@ThePhD o_0
07:32
@LucDanton No, I mean to use the & notation in place of [] as a fallback.
@thecoshman I don't remember who gave you the original advice, but in such situations a common tactic is to make everything revolve around a factory function template rather than the class template.
@Potatoswatter Ah okay.
Is there any case you actually want a polymorphic functor when there's only one overload?
I always want a functor.
Well okay function pointers are functors :(
@LucDanton yeah, factory method was suggest, but that would require a type of auto, would it not, which you can't have in a class
I always want a functor which doesn't cost me one indirection too many!
@thecoshman Not necessarily. You can provide an alias to go in tandem.
07:34
@LucDanton Hmm. Doesn't constant propagation take care of such cases?
it would be nice if I could do something like Glid<glDelete> glid and then just init it either glid() for 'I will get one in a sec' or glid(id) for when I can create it with an int
At which point you should feel compelled what is the difference between having someone spell out a type with an alias rather than a class template :) You can 'overload' the type to which the alias resolves to, much like you can overload the factory function.
@Potatoswatter Sometimes. [](/* args */) { return actual_name_to_be_called(/*args*); } doesn't go through those hoops though.
(Other benefits of having a class type functor are not being nullable, different assignment semantics and playing nice with inheritance.)
@thecoshman I shall write you an example.
As a disclaimer I have a slight headache so this may take some time.
Xeo
Xeo
@Potatoswatter I so don't want to change the semantics of &name
@thecoshman So far, I think handle almost supports all those use cases.
The only problem I have so far is I have to decltype( deleterfunction )
Maybe when I see Luc's example I can get a better idea on how to do mine.
But this looks pretty nice so far. <3
int main ( int argc, char* argv[] ) {
	typedef handle<GLuint, decltype( &glDeleteShader )> GLShaderId;

	GLShaderId id ( glCreateShader( GL_VERTEX_SHADER ) );
	id.reset( 0U );
}
Xeo
Xeo
@Potatoswatter Function object > function pointer. (inlining and stuff)
07:41
Of course, you could use using with C++11 and make it even easier...
@Xeo That's what I was referring to with constant propagation.
Xeo
Xeo
Also, what Luc said about inheritence (yay overload(a, b))
@Xeo Hey Xeo, in my example above, do you know of a way to make handle take a straight function name and have it auto-converted to a function pointer?
@Xeo What's that?
Xeo
Xeo
Although I might need to work out some quirks to make that work for []foo :(
auto overload_set = overload([](int){}, [](double){});
overload_set(42); // calls first lambda
overload_set(13.37); // calls second lambda
@Potatoswatter ^
07:45
LOL, the first line in the function where I just added those std::remove_references to the SFINAE is if ( std::is_reference< s >::value ) return;. Would it be evil just let those two things cancel each other out?
Hnnngggh.
Luuuc hurry up with that awesome name-resolving code so I don't have to use decltttyyyppe.
I wonder, does std::unique_ptr<mytype, MyTypeDeleteFunction> work?
@ThePhD what do you mean, does it work?
@ThePhD it's not so much that your handle class will not do what I want, it's that it does too much :P I would rather have more classes that are well focused then one big class that tries to do everything
If MyTypeDeleteFunction is just a plain old function that takes a mytype pointer, does it actually compile?
@thecoshman I'll get you to use it eventually!
@Xeo Ah yes, I have one of those.
07:49
@ThePhD strip it down to the bare bones then :P
Xeo
Xeo
auto id = make_shader_id(glCreateShader(...), &glDeleteShader);
How often have we talked about factory functions in the last two days?
@Xeo You have to use a function that's templated? D:
Xeo
Xeo
@ThePhD If all deleters have the same type, no.
Well, what I mean is
Xeo
Xeo
07:50
(And no, fuck std::function.)
@Xeo but they don't, some are void(int) and some void(int, int*)
In order to get rid of the handle<GLuint, decltype( &glDeleteShader )> you'd have to do something crazy?
Xeo
Xeo
Define "crazy"
I just want to know if it's possible to make handle<GLuint, glDeleteShader> work.
@thecoshman Remember about words? :p
Xeo
Xeo
07:51
@ThePhD No.
@LucDanton !time
Xeo
Xeo
(FWIW, there's a proposal to allow template parameters to be inferred from later parameters, but I don't know how far that has gotten.)
Oh.
Well, I guess that's livable. Ish. Sortakinda.
well... you could template like handle<someFunc> and take it by value such as template<&void(int) deletor> but that only works for one type of function pointer
07:53
Eh.
Just typedef / using it away or use the factory function. :P
akin to template<int size> class foo{}
Why not just pass an integer to the deleter?
No style_a or style_b
letting you have a function in foo that is different for a certain value of 'size'
Just
@ThePhD that style_a style_b is just so I can have declarations of the syntax
for the use, you would be expected to to template on declytype(&glDeletefunction)
07:55
id_deleter( int size = 0 ); // 0 means call the 1 argument 1, 1+ means call the 2-argument one
Oooh.
but you also have to pass that value of the the address of that delete function to the constructor
Hm. That's doable.
I know
but as I understand it, a template parameter can't be used for both type and value
function_traits to the rescue!
Xeo
Xeo
@ThePhD /slap
07:56
Pretty sure what you're asking is doable.
@Xeo Nooo it's got a legitimate use case here I swear!
I would also like it if the value of the delete function could some how become part of the type of the handler. but this class is mostly and internal class
here you can see how I am using my Glid class.
@ThePhD can't you make something like make_unique, i.e. make_handle? couldn't you auto deduce the type of the deleter function that way, and still have the value as a parameter?
I can have a make_handle, yeah
I think I already do.
I was just asking if it was possible.
@thecoshman How does it work when it's the other form of deleter?
i.e. is the count always 1? I'll assume it is for the time being.
@LucDanton yes, here is a vbo wrapper where the delete is in the format delete(1, int*)
I guess I could do the type deduction for the function pointer with my glid class... so you just template based on the 'value' for the function you want used to delete. Internally, it will call a template function that will look at the type .... but then how do I allow the value to be either type?
08:04
where does tuple and tuple_element come from?
it's like I want to take an int/flot value, as a template value, then internally if it's an int type print "that int is ..." but if it is a float do "that float is ..."
Xeo
Xeo
@ThePhD <tuple>?
... Oh yeah.
@Xeo Look at me, being all naughty with function_traits ~~~
/cc @thecoshman
Xeo
Xeo
@ThePhD /slap
08:06
Whaat, it did its job!
One deleter type, works with both values
@ThePhD but you are still passing the type of function to use, not the function itself
Yes.
It's impossible to avoid.
so how does it know which function to call?
... What do you mean, how does it know?
You give it the function to call. o.0
Xeo
Xeo
@thecoshman It doesn't. ;)
He does what he's best at: Invoking UB.
08:08
glDeleteShader and other version only have one ver- OH WAIT
HERPIN' THE DERPIN'.
@ThePhD no, you are passing it the type of the function, decltype strips the value to just the type
I see what you mean.
Let me use more function_trait magic to fix this~~
Xeo
Xeo
What
WHAT
Shhh, it's going to work out. <3
Xeo
Xeo
PASS A FUCKING FUNCTION POINTER TO THE CONSTRUCTOR OF glDeleter
08:10
erm... can you do something like
template<float value> struct foo{}
template<int value> struct foo{}
Xeo
Xeo
@thecoshman No
that would be too easy :P
Hee.
You could always do some run-time stuff.
If size == 0, call the 1-argument version.
Anything else, call the 2-argument version of the function.
hmm... can you template the constructor?
Xeo
Xeo
Also, wtf R (*T::*)(Args...)
08:11
Member Function Pointer Pointers. <3
Xeo
Xeo
No
@Xeo is that No you cannot template constructor
Xeo
Xeo
@thecoshman Nah, of course you can template the constructor.
Hm.
@Xeo hmm... that might let me do what I want...
08:12
@thecoshman How do you specify which one to call, though?
mydeleter deleter( &glDeleteShader ); is still ambiguous
@ThePhD well, you just pass in the value of the function to call, and it will use template code to work out what style it is, either void(int) or void(int, int*)
posted on June 21, 2013

Moving objects instead of copying them is a tricky notion to explain — and perhaps trickier than I realized.

o.0
But I don't think that solves the problem, does it?
What @thecoshman is referring to having crummy:deleter_a and crummy::deleter_a with two different argument sets.
Not just a and b.
@LucDanton as always :P
08:16
Sometimes the implementation is interesting! This time it's about the separation between deleters, holder_type, holder and Holder though.
...
I'm so fucking confused.
What the hell does thecoshman want to happen with his code?!
hmm... if I used two functions, both of type void(int, int*) but different functions, will this create separate types for the holders? or is there just two types of holder, a void(int) holder and a void(int,int*) holder
Are the deleters named the same, or something different?!
You can try Holder<decltype(&crummy::deleter_a)> h = holder(22, &crummy::deleter_a)); btw, it should work.
@ThePhD I want to template on both type and value at the same time :P
08:18
I do not understand what that means.
Oh well.
@thecoshman If the functions have the same type and you use function pointers as deleters then the resulting holders have the same type.
Whatever, I got in my function_traits usage~
Xeo
Xeo
@ThePhD /slap
@LucDanton oh ok... so not different from what I have already, except a bit easier from the user point of view... at the cost of a what looks to be, more complex class
@Xeo Ahhn, you're so rough Xeo-chan~
08:20
@thecoshman What's the cost of adding more deleters with your situation?
What's it called when your email address contains + in it? Like [email protected]?
@LucDanton you mean a new type of deleter? I would just add a new forward declaration to the name space for the signature, and a new template specialisation for that type that will detail how to go from the single int I am storing to the that style of deletor. Yes that does mean my glid can not take ~any~ delete function, but I do have a fairly well known set of formats
@thecoshman Wait which class is more complex?
of course, another option is to make the user provide a wrapper function. I just call a void(int*) function, it's up to you to then forward that to the gldelete
@thecoshman That's what my example does.
08:23
@LucDanton true, your's is more future proof. I would want to make sure I've understood what it is doing before I use it though.
@LucDanton BTW, OpenGL functions do not throw exceptions. :P
@wilx sub-addressing
according to wikipedia :p
or tagging
idk
@MarkGarcia crummy::delete_a and crummy::delete_b aren't OpenGL functions you silly.
@thecoshman I've also tried what you're currently doing now (creating RAII wrappers for OpenGL objects). It didn't go well, considering the small number of C++11 features I know at that time.
Again, if there's anything to take away from the example it's the separation between holder_type, holder and Holder. I'm repeating myself because it really is the only important point :v Actually implementing them is details.
08:29
@LucDanton actually, how would you expand your example to say use void(known int of value 1, known char of calue T, variable int pointer)
@LucDanton yeah, I will have to take a more carefully look at what exactly you have going on there
Add a holder overload that does the signature -> void(int&) dance.
@LucDanton is that really any easier then my current solution of having to declare a new 'style' and creating a new template specialisation for that style?
one of my most common issues with C++ is that I keep modifying my containers while using them
what can I do about it?
stop modifying them
@thecoshman I don't like that you mix concerns, and you only work with stateless functors.
08:32
I can't stop, an event can trigger
and I need to remove 2-3 items from the container that I am looping through
so I have to loop backwards instead of forwards
Look at that crappy code
@LucDanton what do you mean, sure you could argue that the holder should not have to know how to map to the delete function, but that's not a huge issue. What do you mean only with stateless?
I can add a holder overload for holder(count, handle_array, deleter), while you can't deal with closing over the count to pass to the deleter.
I.e. to call deleter(count, handle_array) at deletion time.
@Grapes Hey. That's your usage pattern. Maybe it's better for you to decide and choose what container suits best your usage pattern than the other way around.
oh, except I have no intention of that :P at least for the now...
@LucDanton what is a holder? I have not used them
08:35
@Grapes perhaps if you didn't interrupt people you wouldn't get confused
besides, IIRC to use the delete(count, baseADDR*) syntax where count is say two, baseAddr would have to basically be an array...
I did call it handle_array didn't I? :p
I just don't see it being a use case I would ever want
You can change template<typename Deleter> struct holder_type; to template<typename Handle, typename Deleter> struct holder_type; and you're done.
I would just have a collection of 'handle'
@thecoshman Ye. That's kinda the point of small, composable pieces of software with limited concerns.
You don't care about the future. You change the piece when the need arises.
What you have is... weird.
08:39
I'll give you that the usage is not very nice
I'm really not in love with function pointers either. I'm always worried they'll point to something else.
but you don't really have anyway to prevent that
um okay then
you do ultimately just have to hope they will give you a deleter that will actually tell openGL to delete the ID
That's how you do software? You hope?
08:42
consoles (i.e. git Bash) look so cool
@LucDanton well, can you come up with a way of ensuring a function is going to do something?
@thecoshman I said nothing of the sort.
the only possible way I can think of, is have some sort tag type for each gl delete function and have them select which tag they want to use for this ID
and whilst that would work, is even less maintainable
Never you mind.
@thecoshman Why won't you just do it the brute-force way? Using those glIs*() functions and deleting the object(s) appropriately. :P
08:44
@MarkGarcia well... it could be done that way... but is even less maintainable
next step, I may as well not bother with the class at all :P
feature not supported, problem solved
08:56
Are there any known issues with Boost 1.53.0 and Visual Studio 2010?

« first day (979 days earlier)      last day (4195 days later) »