visual-c++-2013

std::condition_variable wait_until surprising behaviour

狂风中的少年 提交于 2021-01-27 20:42:42
问题 Building with VS2013, specifying time_point::max() to a condition variable's wait_until results in an immediate timeout. This seems unintuitive - I would naively expect time_point::max() to wait indefinitely (or at least a very long time). Can anyone confirm if this is documented, expected behaviour or something specific to MSVC? Sample program below; note replacing time_point::max() with now + std::chrono::hours(1) gives the expected behaviour ( wait_for exits once cv is notified, with no

How to deduce the return type of a function object from parameters list?

℡╲_俬逩灬. 提交于 2019-12-31 10:32:40
问题 I'm trying to write a projection function that could transform a vector<T> into a vector<R> . Here is an example: auto v = std::vector<int> {1, 2, 3, 4}; auto r1 = select(v, [](int e){return e*e; }); // {1, 4, 9, 16} auto r2 = select(v, [](int e){return std::to_string(e); }); // {"1", "2", "3", "4"} First attempt: template<typename T, typename R> std::vector<R> select(std::vector<T> const & c, std::function<R(T)> s) { std::vector<R> v; std::transform(std::begin(c), std::end(c), std::back

How to limit the number of parallel cl.exe processes during the Visual Studio solution build?

社会主义新天地 提交于 2019-12-22 05:47:26
问题 I've recently noticed that once I start building the Visual Studio solution I'm working with (~200 C++ projects), I get a very large number of cl.exe processes. I'm not surprised by the fact of several cl.exe running in parallel, because my projects are set up with /MP option. But I would expect that their number would be limited by the following setting in the Visual Studio "Options". I presume that running tens of processes in parallel on the 4-core PC is not the most efficient way to build

How to get VS2013 to stop generating calls to __dtol3, __dtoui3, and other functions for casting between integer types?

蓝咒 提交于 2019-12-18 13:22:30
问题 I am in the process of upgrading a Visual Studio 2010 project that targets the INtime RTOS. Code that performs casting operations fail to link. When investigating the "inline assembly" output files, it turns out that for some integer casting operations, VS2013 is generating assembly instructions to calls to __dtol3, __dtoui3, __dtoul3, __ltod3, and __ultod3. The problem is that the INtime libraries do not contain definitions for these functions. I've verified that VS2013 does the same for

IUnknown pointer reference

独自空忆成欢 提交于 2019-12-13 06:12:18
问题 Why is the Visual Studio compiler happy with void fn(int *&i) { ; } and void fn(IUnknown *const &p) { ; } but not void fn(IUnkown *&p) { ; } where calling it looks like IDXGIFactory *df = nullptr; // init df fn(df); compiler error is 3 IntelliSense: a reference of type "IUnknown *&" (not const-qualified) cannot be initialized with a value of type "IDXGIFactory *" c:\Users\Carl\Documents\Visual Studio 2013\Projects\Project1\Project5\main.cpp 29 10 Project5 The closest thing I've dug up with

VC++ 2013: using-declaration + redefinition of member function leads to compile error

▼魔方 西西 提交于 2019-12-12 12:21:39
问题 I want to allow to modify behaviour of my class by specifing policy. This policy shoud be used as visitor for boost::variant. There is default policy that fits most cases good, but user may need to add or replace some overloads. I found that vc++ 2013 doesn't compile this code with error C3066: there are multiple ways that an object of this type can be called with these arguments . Same code compiles and works as expected in gcc and clang. Is it vc++ 2013 bug? #include <iostream> struct

VC++ 2013 Initializer List issue

走远了吗. 提交于 2019-12-12 02:32:19
问题 I've the following code that doesn't compile with vc++ 2013. Is it a compiler bug? class Test { public: Test() : mTestBuff{ 1, 2, 3, 4 } { } private: const vector< int > mTestBuff; }; error C2661: 'std::vector<int,std::allocator<_Ty>>::vector' : no overloaded function takes 4 arguments This compile fine with GCC 4.8 and MinGW. What can I done to remove the compile error? 回答1: Try this: Test() : mTestBuff({ 1, 2, 3, 4 }) { } Demo here. 来源: https://stackoverflow.com/questions/21533191/vc-2013

error MSB6006: “cmd.exe” exited with code 2

回眸只為那壹抹淺笑 提交于 2019-12-11 03:23:46
问题 I had been compiling on my Visual Studio making small changes from the morning and it was running fine. I made a small change and I started getting this error, error MSB6006: "cmd.exe" exited with code 2 I removed that small change I had done. The last change I had made was adding a line to a help text. I have absolutely no clue what this means. Can somebody please help? TIA 来源: https://stackoverflow.com/questions/42620499/error-msb6006-cmd-exe-exited-with-code-2

sscanf fails to read double hex

半世苍凉 提交于 2019-12-06 09:15:25
问题 I need to preserve the exact binary representation of some doubles in a text file with other ascii values, so I am using "%a" as suggested in this question. fprintf (pFile, "Scale: %a, %a, %a\n", scale.x, scale.y, scale.z); However, when I try to read it in with "%la" the scanf returns 0 items read. double x=0, y=0, z=0; fgets(buf, sizeof buf, pFile); int test = sscanf (buf, "Scale: %la, %la, %la\n", &x, &y, &z); // test is zero! When I open up the debugger, I see that the string buffer is

How to deduce the return type of a function object from parameters list?

眉间皱痕 提交于 2019-12-02 20:33:46
I'm trying to write a projection function that could transform a vector<T> into a vector<R> . Here is an example: auto v = std::vector<int> {1, 2, 3, 4}; auto r1 = select(v, [](int e){return e*e; }); // {1, 4, 9, 16} auto r2 = select(v, [](int e){return std::to_string(e); }); // {"1", "2", "3", "4"} First attempt: template<typename T, typename R> std::vector<R> select(std::vector<T> const & c, std::function<R(T)> s) { std::vector<R> v; std::transform(std::begin(c), std::end(c), std::back_inserter(v), s); return v; } But for auto r1 = select(v, [](int e){return e*e; }); I get: error C2660: