visual-c++

SFINAE not working to conditionally compile member function template

旧街凉风 提交于 2021-01-27 23:24:37
问题 I'm trying you use std::enable_if to conditionally choose only one out of two member function template using SFINAE with this code: #include <iostream> #include <type_traits> template<typename T> struct C { template<typename Q = T, typename = typename std::enable_if<std::is_same<Q, int>::value>::type> int foo() { return 1; } template<typename Q = T, typename = typename std::enable_if<!std::is_same<Q, int>::value>::type> int foo() { return 0; } }; int main() { std::cout << C<int>().foo() <<

Where are Visual Studio Debug Source File Directories Saved?

泄露秘密 提交于 2021-01-27 23:23:54
问题 When I go to the properties of a solution in Visual Studio, and add a directory c:\somepath under: "Common Properties" -> "Debug Source Files", where is that directory recorded? In what file? I can't find any trace of it in the following files: mylibrary.sln mylibrary.vcxproj mylibrary.vcxproj.user mylibrary.vcxproj.filters .vs directory 来源: https://stackoverflow.com/questions/50515367/where-are-visual-studio-debug-source-file-directories-saved

std::shared_ptr which is empty but not null

无人久伴 提交于 2021-01-27 22:08:38
问题 http://www.cplusplus.com/reference/memory/shared_ptr/ says A shared_ptr that does not own any pointer is called an empty shared_ptr. A shared_ptr that points to no object is called a null shared_ptr and shall not be dereferenced. Notice though that an empty shared_ptr is not necessarily a null shared_ptr, and a null shared_ptr is not necessarily an empty shared_ptr. Am I able to create an empty std::shared_ptr, i.e. one which does not own anything but which is not null, i.e. contains payload?

MSVC - Creating a static library via Makefile

喜夏-厌秋 提交于 2021-01-27 21:31:45
问题 So I've been trying to create a static library under Windows under MSVC by launching mingw32-make under Microsoft's x64 Command Line Tools. I get linker error LNK1561: entry point must be defined. For completeness, here's my Makefile. all: build\lib\libds.lib build\lib\libds.lib: build\obj\priority-queue.obj link /OUT:build\bin\libds.lib build\obj\priority-queue.obj build\obj\priority-queue.obj: libs/ds/priority-queue.c include/ds/priority-queue.h cl /Iinclude /c libs/ds/priority-queue.c /Fo

How to use Minimal GC in VC++ 2013? [duplicate]

拟墨画扇 提交于 2021-01-27 19:52:18
问题 This question already has an answer here : Garbage Collection in C++11 (1 answer) Closed 7 years ago . According to here, VC++ 2013 supports Minimal GC. Could you guys give me some examples to illustrate its usage? In other words, with VC++ 2013, how to use GC? The code example I want might look like this: auto p = gcnew int; Are there any? 回答1: You may be disappointed about what Minimal GC in C++11: It doesn't do garbage collection! The minimal garbage collection support in C++11 consists of

Formatting wx.TextCtrl with numeric values only - float precision

▼魔方 西西 提交于 2021-01-27 18:02:00
问题 I have created a simple app which uses bare TextCtrl widgets with wxFILTER_NUMERIC in order to accept only numerical values (see code below). I want the values to have a fixed display precision irrespective of how user inputs them (e.g. will always show 17.0000 in case of 17.0 or 17.000000 values being specified). I found that in wxPython there is an option to use a derived NumCtrl widget (http://wxpython.org/docs/api/wx.lib.masked.numctrl-module.html) which does the job but I can't find it

Convert pointer to int and back to typed object

点点圈 提交于 2021-01-27 17:33:49
问题 I need a simple way to convert a pointer to an int, and then back to the pointer. I need it as an int for portability, since an int is easier to carry around in my project than a pointer. Start player and return pointer: SoundPlayer* player = new FxPlayerTiny(); return (int)player; // this works, but is it correct? Stop player using pointer int: FxPlayerTiny* player = static_cast<FxPlayerTiny*>((int*)num); // this gives me an error FxPlayerTiny* player = (FxPlayerTiny*)((int*)obj); // this

Makefile and .Mak File + CodeBlocks and VStudio

混江龙づ霸主 提交于 2021-01-27 14:17:17
问题 I am a little new to the whole makefile concept so I have some questions regarding it. I am creating a project using CodeBlocks in linux, I used a tool called cbp2mak to create a .make file out of the CodeBlocks project (if anyone knows a better tool please let me know). Now I am not sure what the difference is between .mak and .makefile, could anyone tell me? I can compile .mak using "make -C .mak" but what is the difference? The reason im trying to use it is because I want provide the

Are inline static variables unique across modules in visual c++?

孤街醉人 提交于 2021-01-27 12:23:25
问题 c++17 introduce inline (static) variables. It is said that "The compiler will guarantee that a variable has only one definition and it’s initialised only once through all compilation units." I am wondering if visual c++ guarantee inline static variable will be unique across multiple modules (dlls and exe). //cat.h class __declspec(dllexport) Cat { public: inline static int var = 0; }; If cat.h is included in multiple dlls and one exe, is Cat::var unique in the application ? 回答1: Your question

Does MSVC 2017 support automatic CPU dispatch?

一曲冷凌霜 提交于 2021-01-27 07:30:39
问题 I read on a few sites that MSVC can actually emit say AVX instructions, when SSE2 architecture is used and detect the AVX support runtime. Is it true? I tested various loops that would definitely benefit from AVX/AVX2 support, but when run in debugger I couldn't really find any AVX instructions. When /arch:AVX is used, then it emits AVX instructions, but it of course crashes on CPUs that doesn't support it (tested), so no runtime detection either. I could use AVX intrinsics though and it