c++14

Differences between direct-list-initialization and copy-list-initialization

佐手、 提交于 2020-08-18 00:05:32
问题 I would like to know if there is any difference the following two types of std::vector initialization in C++11 and later. std::vector<int> v1 {1, 2, 3, 4, 5}; std::vector<int> v2 = {1, 2, 3, 4, 5}; Here is a complete code example that works fine. #include <iostream> #include <vector> int main() { std::vector<int> v1 {1, 2, 3, 4, 5}; std::vector<int> v2 = {1, 2, 3, 4, 5}; std::cout << v1.size() << '\n'; std::cout << v2.size() << '\n'; } I see both initializations leading to identical results.

Can not access member type from base-class when compiled using c++17 [duplicate]

放肆的年华 提交于 2020-08-17 05:39:18
问题 This question already has answers here : Why do I have to access template base class members through the this pointer? (3 answers) Closed 7 months ago . I have the following code which compiles successfully in c++14. template<class T, class ...Args> class B { public: using AbcData = int; }; template<typename ...Args> class D : public B<float, Args...> { public: AbcData m_abc; }; But when compiled in c++17, it gives the following error. error C2061: syntax error: identifier 'AbcData' What is

Can not access member type from base-class when compiled using c++17 [duplicate]

老子叫甜甜 提交于 2020-08-17 05:38:53
问题 This question already has answers here : Why do I have to access template base class members through the this pointer? (3 answers) Closed 7 months ago . I have the following code which compiles successfully in c++14. template<class T, class ...Args> class B { public: using AbcData = int; }; template<typename ...Args> class D : public B<float, Args...> { public: AbcData m_abc; }; But when compiled in c++17, it gives the following error. error C2061: syntax error: identifier 'AbcData' What is

Practical difference between a struct with only operator() and a normal function

心已入冬 提交于 2020-08-02 07:51:16
问题 I have seen code that looks like this: struct foo_functor { template <typename T, typename U> constexpr auto operator()(T t, U u) const -> decltype(t | u) { return t | u; } }; constexpr foo_functor foo; As far as I can tell, it's the same as the following: template <typename T, typename U> constexpr auto foo(T t, U u) -> decltype(t | u) { return t | u; } Why would you want to do the first one? Are there any differences? As far as I could see from the compiler output, at least with constexpr ,