g++

What is the time complexity of std::map

烈酒焚心 提交于 2020-07-03 02:41:33
问题 What is the time complexity of std::map? And will it degenerate in the worst case? Or it is decide by the implementation, we can't know it? 回答1: Lookups are proportional to log(N). In a typical case (implementation as a red-black tree) the number of comparisons can be up to twice Log 2 N. Insertions are normally proportional to Log 2 N as well--but there's a special provision made for when you're inserting a number of items that are already in order 1 . In this case, you can specify a "hint"

What is the time complexity of std::map

ぃ、小莉子 提交于 2020-07-03 02:41:33
问题 What is the time complexity of std::map? And will it degenerate in the worst case? Or it is decide by the implementation, we can't know it? 回答1: Lookups are proportional to log(N). In a typical case (implementation as a red-black tree) the number of comparisons can be up to twice Log 2 N. Insertions are normally proportional to Log 2 N as well--but there's a special provision made for when you're inserting a number of items that are already in order 1 . In this case, you can specify a "hint"

How to avoid std::filesystem linker errors with Qt?

你离开我真会死。 提交于 2020-06-28 03:07:35
问题 I would like to use the std::filesystem with Qt 5.12.0 with the g++ version Ubuntu 8.2.0-7ubuntu1, but getting linker errors: g++ -lstdc++fs -Wl,-rpath,/home/user/Qt/5.12.0/gcc_64/lib -o qf_filesystem_test main.o -L/home/user/Qt/5.12.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread /usr/bin/ld: main.o: in function `std::filesystem::exists(std::filesystem::__cxx11::path const&)': /usr/include/c++/8/bits/fs_ops.h:121: undefined reference to `std::filesystem::status(std::filesystem::_

How to add an external library in c++ using Cygwin

我们两清 提交于 2020-06-27 18:08:31
问题 I've already wasted time trying to figure this out but no luck so far...I've tried looking through StackOverflow for the same problem but mostly it's related to the IDE people are using, such as VS or Eclipse. I was doing some examples from the Stanford Reader for their C++ course but the code won't work right. I'm trying to figure out how to use external libraries but something keeps going wrong. I'm probably not using the right command but then I don't know which command to use. I'm using

GCC: How to disable heap usage entirely on an MCU?

早过忘川 提交于 2020-06-24 22:42:24
问题 I have an application that runs on an ARM Cortex-M based MCU and is written in C and C++. I use gcc and g++ to compile it and would like to completely disable any heap usage. In the MCU startup file the heap size is already set to 0. In addition to that, I would also like to disallow any accidental heap use in the code. In other words, I would like the linker (and/or the compiler) to give me an error when the malloc , calloc , free functions or the new , new[] , delete , delete[] operators

How to determine what C++ standard is the default for a C++ compiler?

◇◆丶佛笑我妖孽 提交于 2020-06-24 06:15:27
问题 It is frequently mentioned that the -std flag should be used to specify the standard that one wishes to use when compiling a C++ program (e.g., -std=c++11 or -std=gnu++11 ). A related question that is not typically addressed (at least as far as I can tell; see, for instance, the highly-upvoted comment by Dennis under the selected answer by Oskar N.) is how to determine what the default C++ standard that is being used by the compiler is . I believe that it is possible to tell by looking at the

SFML: undefined reference to _imp_ [closed]

坚强是说给别人听的谎言 提交于 2020-06-22 03:52:11
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question I'm trying to create a C++ application with SFML. Followed the tutorial, installed MinGW for Windows. My project has a main.cpp file in its root folder, and SFML is included in lib/sfml (relative to main.cpp). I can compile without problems with the command g++

g++ fatal error no such file or directory

混江龙づ霸主 提交于 2020-06-09 07:02:10
问题 So I am using the gvim editor to program in C++, however when I open a .cpp file on the editor then type :!g++ -std=C++17 file.cpp -o file I get this error: See attached file below: C:\Windows\system32\cmd.exe /c(g++ -std=c++17 file.cpp - o file) g++: error: file.cpp: No such file or directory g++: fatal error: no input files compilation terminated Now is this related to vim, or to my command? Thanks in advance. 回答1: It seems that you're unfortunately using gcc-mingw that doesn't come with

How to cross compile with cmake + arm-none-eabi on windows?

别等时光非礼了梦想. 提交于 2020-05-23 05:12:30
问题 I like to automate the cross compiling for several projects on a Windows build server. I have some problems with the arm cross compiler. Setting it up seems a bit difficult. The cmake compiler check fails with a linking error(see below). My experimental project looks like: main.cpp - a test programm CMakeLists.txt - the cmake build script cmake/STM32F2xx.cmake - the special settings for the ARM STM32F2xx-series I am using 3 Packages: cmake-3.8.0-win64-x64.msi -cmake for windows mingw-w64

g++ - how do I disable implicit conversion from 0 to pointer types?

心不动则不痛 提交于 2020-05-15 06:15:32
问题 Specifically, I want the following code to fail: void a(void*){} int main(){ a(0); // FAIL a(NULL); // FAIL a(nullptr); // success } And I want the following code to compile: void a(int){} void a(void*){} int main(){ a(0); // calls first a a(NULL); // calls first a; that's why I have -Werror a(nullptr); // calls second a } The following code does not compile currently, but should according to my rule: void a(std::size_t){} void a(void*){} int main(){ a(0); // two candidates } Any idea how to