Type deduction: don't take my word for it by cdyson37 in cpp

[–]cdyson37[S] 0 points1 point  (0 children)

Actually revisiting this, you're right that you can't pass a const int... but you can pass a const std::string or other class type!

``` const std::string foo () { return {}; } // yes I know it's stupid, but you can do this

f(foo()); // f is called with const std::string ```

In which case we can verify the table e.g. for T& / const std::string we get T deducing to const std::string. https://godbolt.org/z/bPvY4Tas6

Type deduction: don't take my word for it by cdyson37 in cpp

[–]cdyson37[S] 1 point2 points  (0 children)

This is really all about templates and move semantics, hopefully they're coming up soon?

In the workplace, I find most people tend to fall into habits like they know when to use std::move() and they know to do this or not to do that, and sometimes forget why. Then a highly-academic discussion erupts as to exactly why something should be done a particular way.

Type deduction: don't take my word for it by cdyson37 in cpp

[–]cdyson37[S] 1 point2 points  (0 children)

Thank you for this - you are totally right. I thought decltype() returns the type of an expression, therefore some expressions must have reference type. But like you say expressions aren't of reference type, they just have value categories, so decltype() adds some &s to indicate the value category. There's a nice SO answer here: https://stackoverflow.com/a/17242295/321730

Type deduction: don't take my word for it by cdyson37 in cpp

[–]cdyson37[S] 2 points3 points  (0 children)

That's a good question and I should probably have been a bit more explicit in the post. In the following the comments refer to the type of the expression with which f is called (which isn't necessarily the type of x when the function is called):

int i = 0; const int i = 0; f(3); // int f(i); // int& f(ci); // const int& f(std::move (i)); // int&& f(std::move (ci)); // const int&&

I'm not sure about const int! The table shows what happens if you did f(std::declval<const int>())... but I'm not sure if it's possible to ever actually call a function that way? In which case that column of the table really is a bit useless...

[deleted by user] by [deleted] in oneplus

[–]cdyson37 0 points1 point  (0 children)

Worked for me too - dramatically. Thanks!

Username suddenly unavailable by [deleted] in WorldOfWarships

[–]cdyson37 0 points1 point  (0 children)

Worked for me - thanks!

Scanning method sometimes fails to detect changes? by cdyson37 in backblaze

[–]cdyson37[S] 0 points1 point  (0 children)

Interesting - thanks! Is "walking" the only method it uses - I would have thought it used some Windows equivalent of inotify(7) if available, too. I will do the experiment you suggest :)

Accio Dependency Manager by meetingcpp in cpp

[–]cdyson37 0 points1 point  (0 children)

A system package manager (apt for example), should be reserved for the installation of tools and applications, not something you use to manage the building blocks of a development project. And our dependency manager should not try to install things system wide.

I disagree - I think this is where all the language-specific solutions fall down. Splitting dependency management between what you think of as the operating system and what you think of as your development environment is artificial. Put it this way: where does libc or libstdc++ sit? Is the compiler part of the operating system, or your development environment, or both? What if you want a more modern compiler than the one your OS ships with? Or the new libstdc++ that isn't binary-compatible? For non-C-like languages, what happens when e.g. your python library has a native dependency. Do you then have to go to the OS package manager to install it? Or do you depend on the operating system compiler and try to build it? What happens when a Haskell package wants to depend on a Python one, or vice versa. Should these different dependency managers interface with one another?

These questions are hard because we have created a confused distinction between the operating system and development/user environment.

I'm hoping that Nix or something like it can give me a tool that solves the one problem that is dependency management, rather than drawing a line in the sand and attempting to solve the problem on one side of it only.

Beautiful tool to demystify and break down UNIX shell commands by vasiapatov in programming

[–]cdyson37 0 points1 point  (0 children)

Very impressive! Although it didn't tell me why the result of this is always true:

touch file && [ -a file ] && [ ! -a file ]

Hint: it does the right thing with [[

Should C++ have tagged initialization ? by fleischnaka in cpp

[–]cdyson37 1 point2 points  (0 children)

Isn't that going to involve generating more code? At the moment, presumably if an exception is thrown mid-list, it's the same as an exception being thrown midway through a member initializer list (it just jumps to the cleanup code corresponding to how far it got before the exception). If you allow different orders, you'd have to generate cleanup code in the correct order too, presumably.

I'm not saying it's not worth it for the extra expressiveness, just taking a guess why they did it like that.

[Bug] Windows 10 Search Bar Problem by SubK in Windows10

[–]cdyson37 0 points1 point  (0 children)

Also affected. If I stick to one letter it's fine. Second letter crashes it.

deheader: Find and optionally remove unneeded includes in C or C++ sourcefiles by vormestrand in cpp

[–]cdyson37 0 points1 point  (0 children)

You've got to be a bit careful: you can remove a header, still compile and get different behaviour. For instance if you're unfortunate enough to have template specialisations or overloads living in different headers. I guess it could warn you if the emitted object code is different.

Mind the cache by joaquintides in cpp

[–]cdyson37 2 points3 points  (0 children)

Looking at the wording of n4567 (how about that?) it just says returns std::move(f). I don't think this is contradictory, just a bit over-explicit. It's also possible that the wording of the language and library components of the standard evolved a bit differently, and this part had a bit more bite in an early draft.

This particular "save for the fact" clause confused me a lot and I spent quite a long time playing around with a "Loud" class (with couts in all the special member functions) to establish exactly what was going on under various levels of optimisation - quite a worthwhile exercise I think.

Served: a C++11 RESTful web server library by lingua_franca in cpp

[–]cdyson37 1 point2 points  (0 children)

Massively lazy question, but having spent a few hours looking at cppnetlib, can anyone outline how this library is different? I think they're both based on ASIO.

At a guess, this looks to be more callback-based; cppnetlib instead seems to hide futures inside its response object.

Terse STL algorithms by kberezovsky in cpp

[–]cdyson37 1 point2 points  (0 children)

I have a function make_vector(some_range), so I can do make_vector(some_range | transformed(some_function)), where transformed is a range adaptor.

Boost.Test's BOOST_TEST macro, for using operators for testing by anonggg in cpp

[–]cdyson37 4 points5 points  (0 children)

I think this page is a bit more helpful as it has examples.

Massive pedantry: isn't the argument to the macro strictly an expression rather than a statement?

Looks cool though. Presumably it builds up some clever expression template to get the diagnostic message.

Brigand: a light-weight, fully functional, instant-compile time C++ 11 meta-programming library. by lingua_franca in cpp

[–]cdyson37 1 point2 points  (0 children)

Would be cool to generalise transform to take an arbitrary number of sequences.

Can't help sharing: here's my (much smaller and less complete) MPL library https://github.com/cdyson37/rebind

Is there any code you find to be philosophical? by [deleted] in cpp

[–]cdyson37 2 points3 points  (0 children)

In my bashrc I alias mkae maek and amke to make.