c++17

Cannot generate 32 bit configuration for Visual Studio 2019 with host=x86 or -A Win32

谁都会走 提交于 2020-07-22 06:13:11
问题 I am trying to configure cmake to build for 32bit and 64bit separately... So far 64bit is easy as I just need to add -A x64 cmake -G "Visual Studio 16 2019" -A x64 But I am not able to set 32bit arch. Official documentation suggest -A Win32 or -T host=x86 https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html Even with them I am not able to set x86 host What I have tried: cmake -G "Visual Studio 16 2019" -DCMAKE_GENERATOR_PLATFORM=x86 cmake -G "Visual Studio 16 2019"

which is the full-expression when the rule says the full-expression of initialization

荒凉一梦 提交于 2020-07-20 23:43:15
问题 struct S { constexpr S(int i): I(i),D(i) { } // full-expressions are initialization of I and initialization of D private: int I; int D; }; int main(){ constexpr S s1 = 1; //full-expression comprises call of S​::​S(int) } According to the definition of full-expression: A full-expression is an unevaluated operand, a constant-expression, an init-declarator or a mem-initializer, including the constituent expressions of the initializer, an invocation of a destructor generated at the end of the

which is the full-expression when the rule says the full-expression of initialization

流过昼夜 提交于 2020-07-20 23:43:02
问题 struct S { constexpr S(int i): I(i),D(i) { } // full-expressions are initialization of I and initialization of D private: int I; int D; }; int main(){ constexpr S s1 = 1; //full-expression comprises call of S​::​S(int) } According to the definition of full-expression: A full-expression is an unevaluated operand, a constant-expression, an init-declarator or a mem-initializer, including the constituent expressions of the initializer, an invocation of a destructor generated at the end of the

which is the full-expression when the rule says the full-expression of initialization

白昼怎懂夜的黑 提交于 2020-07-20 23:42:25
问题 struct S { constexpr S(int i): I(i),D(i) { } // full-expressions are initialization of I and initialization of D private: int I; int D; }; int main(){ constexpr S s1 = 1; //full-expression comprises call of S​::​S(int) } According to the definition of full-expression: A full-expression is an unevaluated operand, a constant-expression, an init-declarator or a mem-initializer, including the constituent expressions of the initializer, an invocation of a destructor generated at the end of the

Class Template Argument Deduction - clang and gcc differ

与世无争的帅哥 提交于 2020-07-20 17:04:12
问题 The following code compiles with gcc but not with clang: template<typename T> class number { T num; public: number(T num = 0): num(num) {} template<typename T1, typename T2> friend auto add(T1 a, T2 b); }; template<typename T1, typename T2> auto add(T1 a, T2 b) { // this compiles with both: // return number<T1>{a}.num + number<T2>{b}.num; // this compiles only with gcc: return number{a}.num + number{b}.num; // <== clang is unhappy here } int main() { auto result = add(1.0, 2.0); } Compilation

Reusable member function in C++

烈酒焚心 提交于 2020-07-20 10:05:23
问题 I'm using this member function to get pointer to object: virtual Object* Create() { return new Object(); } It's virtual so I can get pointer to derived objects, now I'm doing it like this: virtual Object* Create() { return new Foo(); } It is working correctly, but I'd like to do something like this to prevent any mistakes and also to make it easier so I don't have to rewrite that function every time I make new class: virtual Object* Create() { return new this(); } I was trying to find how to

Reusable member function in C++

馋奶兔 提交于 2020-07-20 10:03:47
问题 I'm using this member function to get pointer to object: virtual Object* Create() { return new Object(); } It's virtual so I can get pointer to derived objects, now I'm doing it like this: virtual Object* Create() { return new Foo(); } It is working correctly, but I'd like to do something like this to prevent any mistakes and also to make it easier so I don't have to rewrite that function every time I make new class: virtual Object* Create() { return new this(); } I was trying to find how to

c++ compile error 'expected ';' at end of declaration' when using direct brace initialization

荒凉一梦 提交于 2020-07-18 16:24:16
问题 I'm very new to C++, working through my first tutorial, and when I try to compile code from the lesson, I get the following error: expected ';' at end of declaration int x{ }; // define variable x to hold user input (a... ^ ; The full code for the program I'm attempting to run: #include <iostream> // for std::cout and std::cin int main() { std::cout << "Enter a number: "; int x{ }; std::cin >> x; std::cout << "You entered " << x << '\n'; return 0; } I am using Visual Studio Code (v.1.46.1) on

Can a std::function's target callable legally destroy the std::function during execution?

你说的曾经没有我的故事 提交于 2020-07-18 12:50:11
问题 In comments under another question, it was stated that a common mistake is to: invoke std::function when calling it leads to destruction of object which holds it While clearly a "dangerous" thing to do that would be avoided in robust code, is it actually wrong? I cannot find any wording in the standard that ensures: A std::function must not be destroyed by its target callable A std::function 's lifetime must not end during execution of its target callable The lifetime of a functor in general

where's the point of instantiation of static data member template specialization

不打扰是莪最后的温柔 提交于 2020-07-18 10:18:15
问题 Consider the below code: #include <iostream> template<typename T> struct Test{ template<typename U> static U value; }; template<typename T> template<typename U> U Test<T>::value = U{}; //#1 int main(){ auto d = Test<int>::value<int>; } //#2 The [temp.point] section in the standard covers the most case of where the point of instantiation shall place. However I think it's unclear about static data member template, due to: temp.point#1 For a function template specialization, a member function