g++

Are Standard Library algorithms allowed to copy predicate arguments?

喜你入骨 提交于 2019-12-13 14:12:04
问题 Suppose we'd like to remove duplicate values from a vector of int s. The usual solution is to sort the vector and erase duplicates with erase-remove idiom. But we need to mantain the order of the elements that will not be removed, so we can't sort. So one might come up with a predicate like this and use with with remove_if algorithm: struct comp { std::set<int> s; comp() : s() {} bool operator()(int i) { return !(s.insert(i)).second; } }; But this will break if predicate object will be copied

Cannot use g++ for compiling

旧街凉风 提交于 2019-12-13 14:08:55
问题 right now I try to use a opensource tool called " GAUL " where some genetic algorithms are implemented. By compiling the example files I figured out that I can only compile these data via using gcc but not g++. E.x.: 1) Using gcc -I /usr/local/include/ -c wildfire_threat.c -o test.o gcc** -g -O2 -Wall -o test2.out test.o -lgaul -lgaul_util -lm -lpthread -lslang -lm works also the combination gcc -I /usr/local/include/ -c wildfire_threat.c -o test.o g++ -g -O2 -Wall -o test2.out test.o -lgaul

Mac OSX 10.7.4, Xcode 4.4.1, no <array> header file?

时光毁灭记忆、已成空白 提交于 2019-12-13 13:10:14
问题 I am writing a program that will use the array container of the C++ Standard Library to hold some objects. However, whenever I try to include the following line of code in my program: #include <array> I receive the following error at compile time: 75-143-76-177:soft jeffersonhudson$ g++ mms.cpp -o mms mms.cpp:5:17: error: array: No such file or directory 75-143-76-177:soft jeffersonhudson$ Commenting out the #include lets me compile just fine. Surely I am overlooking something simple? I have

assigning true/false to std::string: what's going on?

最后都变了- 提交于 2019-12-13 12:24:26
问题 I was testing a c++11 compiler on my source code and it caught an error in one of my functions that I would have expected my non c++11 compiler to catch as well. I was returning false from a function that has a return type of std::string... Here's the code that demonstrates the problem #include <iostream> int main ( ) { std::string str = false; std::cerr << "'" << str << "'" << std::endl; return 0; } $ g++ test.cpp -W -Wall -Wextra $ ./a.out terminate called after throwing an instance of 'std

Using the g++ C++ compiler from cygwin

二次信任 提交于 2019-12-13 12:02:33
问题 I am trying to execute my first "Hello World!" in C++. I am using Windows XP, and I have installed cygwin, in which the g++ C++ compiler is installed. I have written a small hello-world program, and saved it in hello.cpp. From the command prompt I write: g++ hello.cpp But I get: 'g++' is not recognized as an internal or external command, operable program or batch file. I have installed cygwin in my D:\programs\cygwin. I have made another directory with my hello-world file in D:\cpp. Something

How to build MinGW W64

浪子不回头ぞ 提交于 2019-12-13 11:32:37
问题 I'm new to Stack Overflow, C++ and to MinGW W64. My problem is, is that I don't know how to build MinGW W64, all I know how to do is double click an exe and install the files onto my computer itself. So what I am asking is that, how do you build MinGW W64? ( http://mingw-w64.sourceforge.net/ ) If I learn how to build MinGW W64, I think I will be able to build other things without any help. I don't know what files to get to install MinGW W64. All I know is that I need gcc (for C) and g++ (for

include<apis/api1/api.h> throws No such file or directory

倖福魔咒の 提交于 2019-12-13 09:55:22
问题 #include<apis/api1/api.h> throws No such file or directory i even tried moving api.h and api.cc to the main project directory and using #include<api.h> does the same thing even though it is in the exact same directory that the other classes use i tried adding /apis/api1 to the compiler search path that just crashes the compiler can someone tell me what to type into the compilers compilation line 回答1: #include <api.h> is the way you include a system header. (That is, the header for a library

Prototype… does not match any in Class… (error). g++ [closed]

好久不见. 提交于 2019-12-13 09:49:29
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I am getting a very annoying error with my g++ compiler in Ubuntu. This is my Code. Employee.h #ifndef Employee_h #define Employee_h #include<string> using namespace std; class Employee { protected: int

Why does the function name in .o file different from the one in .cc file after compiling?

时光怂恿深爱的人放手 提交于 2019-12-13 08:58:55
问题 I compiled an .cc file with the following command, which is in Makefile code: bin/bash ../libtool --silent --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include/ -I.. -g -O2 -MT rtpsession_inet.lo -MD -MP -MF .deps/rtpsession_inet.Tpo -c -o rtpsession_inet.lo rtpsession_inet.cc There is a function named rtp_session_rtp_recv in the .cc file. However, it is said that the reference of this function cannot be found when I use the library generated by the Makefile. So I checked the .o

Code running slower with g++ -std=c++0x

送分小仙女□ 提交于 2019-12-13 08:39:41
问题 I was trying to test the difference in the performance of std::swap and vector::swap and I compiled with and without the -std=c++0x option. I have noticed about ~200ms of difference, with the program running faster when I do not include this option. #include <iostream> #include <string> #include <vector> int main() { commentator.setReportStream (cout); size_t nbElts = 2048; vector<int> v, w; v.resize (nbElts); w.reserve (nbElts); for (int i = 0; i < nbElts; ++i) { w.push_back (i); }