|
|
|
|
|
by quotemstr
792 days ago
|
|
In far more cases, zero-cost abstractions make obvious or impossible bugs that would be hard to spot in C programs, e.g. memory lifetime rule violations. And you could make a similar argument that C obscures bugs that would be obvious in assembly. High level languages are a blessing, and programmers who avoid them are only decreasing their productivity and those around them. The problem the article highlights appears to be an implementation defect: in my libstdc++ test just now, we do, in fact, mark the list as nothrow move constructible. The standard should mandate that std::list be infallibly moveable. Are we going to indict a whole programming model based on an isolated implementation bug? If so, well, isn't doing that from a "C is better" perspective the galactic black hole calling the kettle black? #include <cstdio>
#include <list>
#include <type_traits>
#include <vector>
struct Node;
struct Connection {
Node *from, *to;
};
struct Node {
std::vector<Connection> connections;
};
int
main()
{
printf("%d\n", std::is_nothrow_move_constructible_v<std::list<Node>>);
return 0;
}
|
|