« first day (763 days earlier)      last day (4187 days later) » 

11:01 AM
auto deleter = std::bind(&IrrlichtDevice::closeDevice, _1); std::unique_ptr<IrrlichtDevice, decltype(deleter)> p { /* raw pointer */, deleter }; is one way.
 
Ell
std::unique_ptr<irr::IrrlichtDevice, decltype(std::bind(&irr::IrrlichtDevice::closeDevice))> engine; is another?
 
That's not guaranteed to work I think.
To clarify: there's no guarantee that the result of a call to std::bind be default constructible. So it's fine if it's a member declaration.
In any case it's the exact same way, when it works.
 
Ell
yeah
 
11:22 AM
SPARSE MATRICES
 
Ell
why can't I do this?:
auto IrrResourceCache<class T, std::string DirPrefix>::operator[](std::string name) -> T& {//... }
 
2
Q: Change bit of hex number with leading zeros in C++,(C)

FreesI have this number in hex string: 002A05. I need to set 7-th bit of this number to 1, so after conversion I will get 022A05 But it has to work with every 6 chars hex number. I tried converting hex string to integer via strtol, but that function strip leading zeros. Please help me how ca...

whoa
 
Ell
ahh nevermind you can't use std::string in templates
 
@Ell ? that's a weird statement in isolation
But yeah, you can't use a non-integral constant as a template argument for a non-type template parameter
 
11:38 AM
@R.MartinhoFernandes I thiss this counts as compile-time benchmarking.
2
 
Ell
ahh well. That's annoying >.<
 
You can of course you std::string in a template. You can even use it in a template-id
@LucDanton Where is that from / what is it about
 
Ell
I guess I'll just make it runtime then, bit annoying though
 
@Griwes whoa about the java programmer who doesn't know integer representations?
 
@sehe I have written a utility that shuffles a tuple. For instance you can write std::tuple<int, double> t = shuffle(std::make_tuple(42., 3)); and that does the right thing. I was wondering what was the impact of using it on compile-time.
 
11:39 AM
@Ell Well, what values would be in the string? If they are a known domain escape using (a) a perfect hash (b) (char&)[] externals (they are compiletime integrals) or (c) using an enum or something of the sort
 
@R.MartinhoFernandes Previous message meant to say 'I guess'.
 
@LucDanton mmm. I'm pretty sure that shuffle implies randomness. I'd name it 'reorder', 'match' or 'permute'?
 
@sehe Why hasn't anyone told me this earlier.
 
@LucDanton I presume irony there. Likely this has been mentioned about a dozen times?
 
No.
 
Ell
11:42 AM
@sehe they would be file paths
 
@LucDanton Well, I'm not sure how you'd get compiletime PRNG going, so IRL most devs won't actually expect random results :) auto no_clue = shuffle(make_tuple("bananana", 23, 3.14)) :)
 
While I did know of that meaning of 'shuffle' I also thought one of the meanings was 'reorder'.
 
Ell
for resources (e.g. Images, meshes, maps, etc.)
I guess I could write one, then specialize with the directory prefix
 
@Ell "The" file paths? You realize that is exceedingly unclear? It could be user input, which makes it impossible for compiletime, or FILE, which would not be impossible
@Ell Wait, how on earth would instantiating new types and function instances be profitable for that?
 
@sehe Not sure which to pick between 'reorder' and 'match'.
 
11:44 AM
@LucDanton regroup, rearrange - just thinking alike. For artistic value: anagram
 
std::tuple<T, U> u = reorder(t); or std::tuple<T, U> u = match(t);. Second one doesn't work as well I would think.
 
@LucDanton Reorder looks pretty sweet. Rearrange would also work, I think
 
Ell
@sehe well basically I could avoid writing "Media/Images" and "IVideoDriver::createImage()", and instead just one call to ["MyImg.png"]
 
If it helps it's not incorrect to view the result of op(t) as a 'view' into t.
 
Ell
but I could just specialize for whichever resource type, right? instead of using a string
 
11:45 AM
Match is too general: has associations with searching and pattern matching
 
Ell
ignore me, I think I know what I'm doing.
 
And in fact something like op<int&>(t) = 42; will assign 42 to the first thing (left to right) that binds to int& (it's a bit more involved, but you know).
 
@LucDanton So you could name it "unordered_bind", "tie_across" or something more semantically loaded?
@Ell template masturbation :)
 
Ell
haha, it's my first time experimenting ;)
 
(op<T, U, V>(foo) is shorthand for std::tuple<T, U, V> { op(foo) }. Plus there's no cast notation and so on.)
 
11:47 AM
@Ell You're entitled to a little masturbation then. Just like any 12y/o :) But you should stop clear when you wanted to do non-integral non-type params :)
 
Perhaps a past participle? reordered<int&, long>(t)?
 
Ell
@sehe basically, what I want is to be able to do images["something.png"], maps["a_map.dat"] and audio["song.ogg"] without having to write ImageCache, MapCache, AudioCache classes. I might be able to manipulate std::map to do it, though
 
reorder(t) might otherwise be understood to mutate t or otherwise operate on it.
 
user1357851
I find 12 yo doing C++ scary
 
Ell
is there a type which can take an abstract class and a function to act as a default constructor for it?
 
user1357851
11:53 AM
void*
 
Can you express what you want with code?
 
hi, all
long time no see
 
Ell
ahh I don't know what I'm talking about.
2
 
user1804599
@JerryCoffin the text was copied directly from Wikipedia. :)
 
user1804599
@Ell you can make the ctor private and write a friend factory function.
 
12:05 PM
@Aardvark It's an abstract class.
 
user1804599
I'm going to add bump mapping to my WebGL app today.
 
user1804599
Why would you want a function that acts as a default constructor for an abstract class?
 
user1804599
class Nokia3310 {
public:
    ~Nokia3310() = delete;
};
 
Ell
@Aardvark well basically I want to be able to do images["tex.png"], but in Irrlicht, it's all IImage which is abstract. so you have to do driver->createImage(path). So I was just thinking of putting something which simulates the ctor, so I could do this; std::map<add_ctor<IImage, &createImage>, &deleteImage> (pseudo/crap code)
 
user1804599
Ooh.
 
12:12 PM
I hate the unstandardized international education system. :(
 
user1804599
template<class T, class F>
class add_ctor {
public:
    template<Args...>
    add_ctor(Args&&...) : obj(F()(std::forward<Args>(args)...)) {}
private:
    T* obj;
}
 
user1804599
Something like that @Ell?
 
user1804599
You need to add some more things, of course.
 
the fact that it's unstandardised is the biggest problem with education?
 
user1804599
The biggest problem with the education system is that everybody has the same level of dumbness.
 
12:13 PM
struct delete_delete
{
    void operator delete(void*) = delete;   // :)
};
@Aardvark Not everybody. Some are even dumber!
 
user1804599
@FredOverflow not to the educators. Everybody is the same, it's like communism.
 
Ell
@Aardvark probably - I can't really do templates :P
 
@DeadMG well, kind of. Look at my condition. I'm doing the SAT for american unis. The A Levels for all other unis on earth. And the Omani GED just because it's compulsory in the educational slum of a country I live in.
 
@Ell Why not? Forbidden?
 
user1804599
@Ell why are you using an inferior library like Irrlicht anyway?
 
Ell
12:14 PM
@FredOverflow I mean skill level wise, I just haven't learnt about variadic arguments and stuff
 
@ApprenticeHacker The problem is that the places you're applying to require pathetic examinations in the first place.
 
Considering this is my second last high-school year, I need to take 3 examinations in 2 years
 
Ell
@Aardvark it's easy to get working, small in size, free and stuff
 
@DeadMG yeah. But what should they require? I mean, how else can you judge a candidate?
 
user1804599
It is not easy to get working since it uses pointers everywhere.
 
user1804599
12:16 PM
Irrlicht makes it fdifficult to write exception-safe code.
 
Ell
Yeah I noticed that :/
but don't know what else to use
ogre3d hates me on windows :P (and is full of singletons)
 
@ApprenticeHacker Why don't you ask candidates to complete some non-trivial coursework instead?
 
user1804599
Use OpenGL or DirectX directly.
 
or, hell
 
Ell
@Aardvark that wouldn't make writing exception-safe code any easier would it?
 
user1804599
12:17 PM
Or use three.js and CoffeeScript. :P
 
why don't you just ask candidates to impress you and see what they come up with?
@Aardvark std::unique_ptr?
 
@DeadMG hmm.. you know that actually makes more sense.
 
Ell
@Aardvark what does the && mean in Args&&...?
 
i discovered that matplotlib now (says that it) supports python 3.x!
wow
 
But I guess the unis just love to torture us with a ton of exams. :(
 
user1804599
12:19 PM
@Ell Something with rvalue references if I'm correct. Or maybe not.
 
user1804599
&& always confuses the hell out of me unless it means logical and.
 
user1804599
 
And the one thing I don't understand. A Level requirements for Software Eng. => Maths, Physics, Chemistry. (Preferably at least an AAB). When is chemistry ever used in programming?
 
@Ell std::map ftw
 
@Ell If T is a template parameter, T&& is a Universal Reference.
 
Ell
12:26 PM
@ApprenticeHacker chemistry is a very difficult a level, it shows you have intelligence?
 
user1804599
@ApprenticeHacker in chemistry-related applications.
 
@Aardvark I simply use and instead of && when I mean logical and :)
 
user1804599
I simply use superior languages. :)
 
19
Q: The written versions of the logical operators

Kavon FarvardinThis is the only place I've ever seen and, or and not listed as actual operators in C++. When I wrote up a test program in NetBeans, I got the red underlining as if there was a syntax error and figured the website was wrong, but it is NetBeans which is wrong because it compiled and ran as expecte...

 
♪ delete_delete, ♫
Oh, with your eyes so blue
delete_delete ♬
I've got a crush on you
delete_delete ♩
I'm so in love with you
 
12:27 PM
My favorite is compl
 
Ell
@Aardvark can you help me make this work? ideone.com/UWKlBB
 
@ApprenticeHacker erm. it's called tests. tests ensure that your certificate is worth something. This is what you actually pay for. Why complain?
 
@Xeo Say, were you aware that 'to shuffle' means 'randomly reordering' specifically?
 
Xeo
@LucDanton Yes. I was slightly wondering why you chose to name the function as such. :)
 
12:33 PM
I had no idea. I renamed all that stuff to reordered.
 
Xeo
hrhr
 
Neat graphs of compile-time benchmarking btw.
 
Xeo
reordered_to, maybe. Or reorder_to.
 
reordered is in the spirit of the Boost.Range adaptors.
I.e. argument is not modified but result is an interesting view into it.
 
Xeo
Yeah, but do you write make_tuple(...) | reordered<...>? :)
 
12:36 PM
lol
 
Xeo
The normal function-style form of the adaptors is imperative, e.g. transform, slice, stride, etc.
Btw anyone working with tuples should know that you can't reorder them in-place if you got different types.
 
user1357851
 
Xeo
@LucDanton How exactly did you make those? I always wanted to try and benchmark my TMP stuff.
 
Ell
function call can't appear on constant expression - don't understand why this is a constant expression?: ideone.com/cDwujA
 
@Xeo Wrote a script that invokes GCC and times it.
 
Xeo
12:47 PM
And for the graphs?
 
The invocation also defines ITERATION, it's up to the benchmarked program to make use of it so that successive invocations measure something.
I used R.
 
Xeo
@Ell add_ctor<T, Factory> : obj(Factory()) -- ehm?
Did you mean add_ctor(Factory f) : obj(f())?
(note that you absolutely need to pass an object if Factory is a function pointer.)
 
Ell
@Xeo why? o.O
 
Xeo
Well, if you just write obj(Factory()()), you're invoking a null function pointer, aka UB
 
@Ell Because a value-constructed function pointer is NULL, like any other pointer.
 
Ell
12:55 PM
don't understand why it's a null function pointer? aren't you passing the pointer in as a template argument?
 
Xeo
you only pass the type.
 
Ell
right. because of the decltype(). of course.
can I pass the value to the template?
 
I want the ability to make distinct fun object types that default initialize to non-null from fun names.
Also, hallo.
 
Ell
hello :) you're a template genious, can you help me write this thing? or alternately write it for me :3
 
@R.MartinhoFernandes Germanization complete, it seems :)
 
1:03 PM
@Ell I don't know what you are trying to do. And I had planned to make use of my German learning books today :)
 
@Ell Flattery doesn't work on robots.
 
@FredOverflow hehe
 
Xeo
@R.MartinhoFernandes decltype([]fun_name)? :) (my currently preferred style for my non-existent proposal for lifting functions to function objects)
 
I don't even.
 
@R.MartinhoFernandes Was lernst Du heute genau?
 
Xeo
1:05 PM
@LucDanton What?
 
@Xeo Let's []put tokens() everywhere{}!
 
@FredOverflow I haven't started yet :S
 
Xeo
@LucDanton Well, the syntax stems from the fact that it's a shorthand for the following:
 
Ell
when did you learn german? :L
 
@R.MartinhoFernandes I thought you had made concrete plans :)
@Ell He works in Berlin now.
 
Xeo
1:07 PM
[](&&... vs){ return fun_name(std::forward<decltype(vs)>(vs)...); }
 
Ell
That was my attempt at a translation :3
I really need to start sleeping more and talking less ambiguously >.<
 
Xeo
@Ell "What do you learn today, specifically?"
 
@Ell No, I was asking "What exactly are you going to learn today?"
 
Ell
ahh okay
 
Xeo
I mean, if we had the ability to pass identifiers as template arguments, we could make it a template: template<identifier Name> auto lift(){ return [](&&... vs){ ... }; } and then call lift<fun_name>().
 
user1804599
1:10 PM
template<identifier foo> would be so awesomeawesomeawesome.
 
Moar kinds!
Polymorphic kinds too!
 
// from the systrace source code:
int intercept_translate(struct intercept_translate *trans, int fd, pid_t pid, int off, void *args, int argsize);
struct intercept_translate ic_translate_string = { "string", ic_get_string, ic_print_filename, };
 
Xeo
template<auto X>!!
 
^ How is that valid? Same name is used for struct and function. Struct is defined using array syntax.
 
Xeo
@StackedCrooked Implict namespaces... functions live in different ones than structs, so to speak.
 
1:12 PM
structs have their own namespaces in C.
 
Xeo
@StackedCrooked That's just aggregate initialization btw.
 
user1804599
template<class T>
namespace numeric_limits { ... } // FTFY, Standard
 
Does it work in C++? The snippit is C code btw.
 
Yes, you disambiguate in C++ with struct X instead of X.
 
Xeo
Sure. C++ also has the so-called elaborate type specifiers.
 
Ell
1:14 PM
hmm. So how do I get a template to accept a function pointer value?
 
Xeo
template<class T, class Fun, Fun f> struct X{}; X<int, decltype(my_fun), my_fun> x;
 
user1804599
Oh.
 
@FredOverflow Ah, now I understand. The struct keyword is used for disambiguating, I thought it was used as a forward declaration (followed by a definition where member types are type-inferred).
 
user1804599
In C, struct is required unless you typedef.
 
I like writing the struct prefix in C.
 
user1804599
1:30 PM
Me too.
 
it's redundant.
 
Ell
What's wrong with this now? o.O ideone.com/uR7XNj
 
Xeo
f()()
Do a bit of thinking yourself.
 
Ell
I only put the second bracket there because it was there earlier :L
 
Xeo
It was there to create the Factory object, and then call that.
 
1:35 PM
@Xeo In reply to your comment, are you saying the second function can make use of NRVO?
 
Ell
Ohh right. Ahh got you
 
Xeo
@Pubby Naw, see the part in parens.
 
@Abyx redundant like the std:: prefix? ;)
 
@FredOverflow nope.
 
Xeo
It was a reply to the "both are equally likely to be elided" part.
 
1:36 PM
Couldn't non-NRVO elision happen though?
 
Xeo
Err... RVO is copy elision for return values oO
It just has a special name, for some reason.
But it's copy elision all the same.
 
I mean isn't RVO and NRVO different?
 
It's the name of the compiler optimization. Or an optimization.
 
Ell
doesn't it have that name because it existed before move existed?
 
Xeo
@Pubby RVO -> copy elision from temporary, NRVO -> copy elision of named local variable
 
1:39 PM
I'm still confused :S
 
Are there any unnamed local variables? ;)
 
Today's possibly dumb idea: since you can't specialize a function template in arbitrary namespace, why not let it call an overload, because one can overload everywhere?
I got code like this:
 
return temp; vs return std::move(temp) where temp is rvalue reference. Both have same elision possibilities?
 
    //template< class Type >
    //inline String progId( TypeCarrier_< Type >::Invariant );              // Specialize.

    template< class Type >
    inline String progId()
    {
        auto const typeCarrier = TypeCarrier_< Type >::Invariant();
        return progId( typeCarrier );
    }
 
@Pubby Note that named rvalue references are still lvalues.
 
1:41 PM
I am a little unsure about ADL here, but it seems to work
 
@FredOverflow I don't understand how that's relevant to elision
 
with Invariant defined as Type**
@Pubby in return statement it is as if move was applied implicitly. roughly.
 
Xeo
@Pubby Yeah. Both would be RVO, eliding the temporary object used to initialize the return value.
@Cheersandhth.-Alf Not for temp, it's a reference type.
 
@Cheersandhth.-Alf I thought the rule was only against partial specialization. In which case overloads wouldn't help much.
 
Ell
1:43 PM
right, it works now :3. Now I need to get it to infer and forward stuff
 
Xeo
make_added
 
@Pubby well no it's about the general rule for templates. can only be specialized in original namespace or enclosing one
 
German Metal professer lol
 
@FredOverflow huh, where ist metal music?
 
He just looks metal.
 
1:53 PM
i think he looks prime
prime professor
or prima professor
 
user1804599
 
user1804599
^ Heavy metal. :)
 
user1804599
23 hours ago, by Tony The Lion
 
@Aardvark What is that, Viagra made from Uranium? :)
 
user1804599
1:59 PM
No, that's uranium on a reflective surface. :P
 
Ell
if it only takes 18 years to fly a jet to the sun, surely we can get people to mars?
 
yeah, they'd "only" have to spend six months cooped up in a tiny metal capsule.
with all the horrific effects of microgravity
 
user1804599
You can simulate gravity using a centrifuge. :P
 
Ell
well I know it's difficult but I had the impression it wasn't at all possible with current technology
 
@Aardvark That should fix it.
 
user1804599
2:01 PM
Fix all the bones!
 
@Aardvark it is interesting because due to relativity the circle should be shorter when spinning.
 
user1804599
Problem is that you have funny weather on Mars.
 
Ell
I think ima give up on this whole template thing :P
 
as einstein-man himself noted & discussed
 
@Ell The only real difference from "Impossible" to "Would cost so much money that it's basically completely unfeasible."
I mean, the weight of a capsule with enough air, food, water, for six months, for several people? Plus all the propellant
 
Ell
2:02 PM
yeah
 
you'd practically have to construct the thing in space, it might not even be able to launch from Earth
and the cost of the whole thing would be astronomical
 
user1804599
Travel at warp speed! Or use a worm hole.
 
and you know what? There's really no reason to send people to Mars
 
Ell
@DeadMG but we have to beat the russians :O
 
the thing to do is to build big accelerator on the moon
 
2:04 PM
It's not like there's a better reason for staying on earth
 
but nasa not interested in moon
only china and russia
 
user1804599
We need to get the fuck out of here before the year 4000000000. :)
 
Ell
There might be a massive diamond in the middle :P
 
I thought the world ended next month
 
user1357851
no, that's the new beginning
 
user1804599
2:06 PM
No, that's Mayan bullshit.
 
nah
 
user1804599
Ah well, it's good for the world population, which is too high.
 
afaik, they didn't predict the end of the world in 2012, they just didn't bother to keep their calendar going
which is quite understandable, since it's like, 5,000 years ago
and it's really quite a stupid thing anyway
 
@DeadMG They could learn C++ on the way. Never gets boring.
 
Ell
yeah. They were rather over-ambitious :L
 
2:07 PM
@FredOverflow Wouldn't be done by the time they got there.
 
user1357851
like that nostrodumbass
 
But they could study 24/7 :)
 
user1804599
@FredOverflow Haskell, since they are all mathematicians. :P
 
user1357851
pity they did not create casinos
 
user1357851
where they can put their maths into good (and profitable usage)
 
user1804599
2:09 PM
> Warning: Scientific accuracy is not guaranteed. Please do not use this visualization for interstellar navigation.
 
user1804599
LOL
 
user1804599
Typical Google joke.
 
@Aardvark What did you google for?
 
user1804599
@FredOverflow Nothing.
 
user1804599
It was in the info page of 100,000 Stars.
 
user1357851
2:12 PM
Search for 'nothing' has generated about 1,840,000,000 results (0.25 seconds)
 
user1357851
gg
 
user1804599
ok
 
i had forgotten all about joan baez, suddenly i'm clicking my way into the old physics faq
@Telkitty he he
 
Ell
2:30 PM
oh gawd I didn't chlorinate the tub :S
oh godd if my bros b-day is ruined because of this I am deadddd
 
wat dafuq are you doing?
 
Ell
le hot tub has gone murky-ish because I didn't check it & chlorinate yesterday
he is having friends over today to go in it. I have 5 hours for the chlorine to do the magic but I'm certain it's too late
so I'm le screwed and I've ruined my bros bday :'( and possibly the hot tub
which I can't afford to replace :P
 
@Xeo I quoted the standard of course, and (probably the important part) pointed out how the part of the standard I quoted fit together with what he'd quoted, and what the result of that was/should be.
 
@sbi whoa. I went the other mile again :) stackoverflow.com/a/13431504/85371
 
Xeo
@JerryCoffin What specifically did you quote? From his quote, it seems clear that unless std::ate is specified, you should get overwrite.
 
2:44 PM
§27.5.3.1.4/1: "app seek to end before each write".
 
@Pubby curious incident: a message referring to stars in the lounge didn't attract self-referential stars. That's a first
2
 
@Ell Seems odd to me that you can physically ruin a hot tub by missing a day chlorinating it. What do people do when they go on holiday when they have a hot tub?
 
@DeadMG He didn't say that it needs to be done daily. Just that it needed to be done yesterday
 
Ell
@DeadMG well it wouldn't ruin the hot tub - it might mean draining it and refilling and reheating it which is quite expensive
 
@sehe I didn't say daily either.
 
2:48 PM
@Xeo So, the effect is fairly simple: when/if you specify ate, it should seek to the end as you create the stream. If you specify app, it should stay positioned at the beginning when you create the stream, but seek to the end immediately before doing a write. For example, if you specify app, and call tellp, it should return 0. Only after writing to the file should it have seeked to the end.
 
Xeo
I see
 
If all you are doing is appending, ate is more efficient, then, right?
Theoretically. Possibly not noticeable.
 
@R.MartinhoFernandes Yes, I think that covers it pretty accurately. In theory, app will involve a seekp before every write, where ate only involves one when you create the stream. Given that you're doing I/O, however, the time to do a vacuous seek is likely to be buried in the noise.
@Aardvark You should know better than to trust Wikipedia about matters of such grave importance! :-)
 
user1804599
I added a bump map.
 
Ell
@Aardvark lemme see!
 
@R.MartinhoFernandes I should probably add one more detail though: that depends on you're having a non-stupid implementation of Iostreams. It was (thankfully) a long time ago, but I've seen implementations that didn't bother checking that the seek destination was exactly your current position -- every seek invalidated the current buffer contents. In that case, all seeks were fairly expensive.
 

« first day (763 days earlier)      last day (4187 days later) »