Tag: c++17
-
What is the purpose of _t aliases and _v variable templates for type traits?
7 There are a lot of *_v and *_t suffixes, like std::is_same_v, std::invoke_result_t, result_of_t and milions of other such functions. Why do they exist at all? Is it beneficial in any context to expose implementation details like std::result_of::type or std::is_same::value? Ignoring standard compliance, should the _v _t versions always be preferred? Could the ::type ::value…
-
Why is there no parallel `std::accumulate` in the C++ standard?
7 I think it is confusing that there is no parallel version of std::accumulate in the C++ standard. It appears to me that it would be trivial to implement it in parallel, for instance, based on OpenMP or SIMD instructions. Does anybody have a good explanation for why the standard committee chose to introduce a…
-
Why does the derived class have access to the private field of the base class?
10 class Base { public: class FirstBase { friend class Base; int x = 10; }; class SecondBase : public FirstBase { public: SecondBase() : FirstBase() {} void t() { std::cout << FirstBase::x; } }; }; This code compiles and works, but I don’t understand why it works. Can explain or cite sources to read?…