Better HN
topnewbestaskshowjobs
Log inSign up

merogin

15 karma · joined Aug 19, 2015 (11y ago) · 4 submissions

Submissions

comment 11y ago · link · parent

And it won't work when switching the parameter order of byval, so you're correct. That's quite nasty.

comment 11y ago · link · parent

Do you mean something like this? http://ideone.com/8tPPHy

comment 11y ago · link · parent

  Some people might ask why I chose to make the parameter of BlackBox::store an rvalue reference rather than an lvalue reference and force the client code to use std::move. While it is true that an lvalue reference would also have worked, if I did that, it would be impossible to write code like crate.store(std::make_unique<Gadget>(beeper, flasher));. I also happen to think that forcing the client to use std::move at the call sites is good rather than bad, because it communicates the intended effect to the reader.

Passing unique_ptr by value is the correct option here, it will accept temporaries just fine.

And in my opionion, if you want safety quarantees like that, use Rust. I was a fan of the new C++ standards a while ago, but after having used them for some time, I found C is a lot nicer language. There's just way too much mental overhead when trying to write "idiomatic C++" and the compiler errors you sometimes get are just a waste of developer time.

comment 11y ago · link · parent

I haven't used the application (can't on Linux), but if the graph doesn't require user interactivity, using Cairo or some other software renderer (e.g. http://www.antigrain.com/) to just render the graph into a bitmap, would do the job faster and with less resource usage. Adding user interactivity on top of that shouldn't be a lot of work either.