std

STL namespace problem in Netbeans 6.8 on AIX

I'm trying to use NetBeans 6.8 on an AIX OS for C++ development. I continue getting an error message for: using namespace std; even after adding the includes for the STL via options -- c/c++ -- code assistance The error says: "Unable to resolve identifier std" Is this a bug in the Netbeans 6.8 AIX version? Or am I missing som...

Vector of vectors of T in template<T> class

Why this code does not compile (Cygwin)? #include <vector> template <class Ttile> class Tilemap { typedef std::vector< Ttile > TtileRow; typedef std::vector< TtileRow > TtileMap; typedef TtileMap::iterator TtileMapIterator; // error here }; error: type std::vector<std::vector<Ttile, std::allocator<_CharT> >, std::alloc...

C++ cin problems. not capturing input from user

I have the following method which is not capturing anything from the user.If I input New Band for the artist name, it only captures "New" and it lefts out "Band". If I use cin.getline() instead nothing is captured. Any ideas how to fix this? char* artist = new char [256]; char * getArtist() { cout << "Enter Artist of CD: " << endl;...

c++0x, std::thread error (thread not member of std)

Hello I compiled & installed gcc4.4 using macports. When I try to compile using -> g++ -g -Wall -ansi -pthread -std=c++0x main.cpp...: #include <thread> ... std::thread t(handle); t.join(); .... The compiler returns: cserver.cpp: In member function 'int CServer::run()': cserver.cpp:48: error: 'thread' is not a member of 'st...

std::for_each on a member function with 1 argument

I'm wondering how to implement what is stated in the title. I've tried something like... std::for_each( a.begin(), a.end(), std::mem_fun_ref( &myClass::someFunc ) ) but I get an error saying that the "term" (I"m assuming it means the 3rd argument) doesn't evaluate to a function with 1 argument, even though someFunc does take one argume...

c++ ifstream: how can i skip forward several lines ?

Hiya. I'm using std::getline to read lines from a file, how can I move forward a few lines? do I have to use getline the number of lines I want to skip? thanks! ...

How to check if a position inside a std string exists ?? (c++)

Hello, i have a long string variable and i want to search in it for specific words and limit text according to thoses words. Say i have the following text : "This amazing new wearable audio solution features a working speaker embedded into the front of the shirt and can play music or sound effects appropriate for any situation. It's j...

operator << overload

//using namespace std; using std::ifstream; using std::ofstream; using std::cout; class Dog { friend ostream& operator<< (ostream&, const Dog&); public: char* name; char* breed; char* gender; Dog(); ~Dog(); }; im trying to overload the << operator. I'm also trying to practice good...

Why doesn't ifstream read to the end?

I'm making a notepad-like program. To get the text from a file I read each character into the buffer by doing while (!file.EOF()) { mystr += file.get(); } however if I load in an exe it stops after MZ but Notepad reads the whole exe. I set my ifstream to binary mode but still no luck. What am I doing wrong? Thanks code: (messy) vo...

Using numeric_limits::max() in constant expressions

Hello, I would like to define inside a class a constant which value is the maximum possible int. Something like this: class A { ... static const int ERROR_VALUE = std::numeric_limits<int>::max(); ... } This declaration fails to compile with the following message: numeric.cpp:8: error: 'std::numeric_limits::max()' cann...

Reading lines from a file using std:: istream_iterator. Who?

Possible Duplicate: How do I iterate over cin line by line in C++? I need to read all lines from a file: std::ifstream file("..."); std::vector<std::string> svec( (std::istream_iterator<std::string>(file)), (std::istream_iterator<std::string>()), ); but it is read as words. ...

Segmentation fault in std function std::_Rb_tree_rebalance_for_erase ()

(Note to any future readers: The error, unsurprisingly, is in my code and not std::_Rb_tree_rebalance_for_erase () ) I'm somewhat new to programming and am unsure how to deal with a segmentation fault that appears to be coming from a std function. I hope I'm doing something stupid (i.e., misusing a container), because I have no idea how...

C++: Why does space always terminate a string when read?

Using type std::string to accept a sentence, for practice (I haven't worked with strings in C++ much) I'm checking if a character is a vowel or not. I got this: for(i = 0; i <= analyse.length(); i++) { if(analyse[i] == 'a' || analyse[i] == 'e' [..etc..]) { ...vowels++; } else { ... ...consonants++; } This works fine if the strin...

C++ - Implementing my own stream

Hello! My problem can be described the following way: I have some data which actually is an array and could be represented as char* data with some size I also have some legacy code (function) that takes some abstract std::istream object as a param and uses that stream to retrieve data to operate. So, my question is the following - wha...

Creating Binary Block from struct

I hope the title is describing the problem, i'll change it if anyone has a better idea. I'm storing information in a struct like this: struct AnyStruct { AnyStruct() : testInt(20), testDouble(100.01), testBool1(true), testBool2(false), testBool3(true), testChar('x') {} int testIn...

Concatenate boost::dynamic_bitset or std::bitset

Hey, what is the best way to concatenate 2 bitsets? For example i've got boost::dynamic_bitset<> test1( std::string("1111") ); boost::dynamic_bitset<> test2( std::string("00") ); they should be concatenated into a thrid Bitset test3 which then holds 111100 Solutions should use boost::dynamic_bitset. If the solution works with st...

How can I make a std::list of arrays?

I would like to make an std::list of arrays. specifically, I want a list of arrays of Borland Code Builders AnsiStrings. the real kicker being that I would like the arrays to be allocated dynamically. How do I define the list? Im so lost here i dont know were to begin. std::list<???> myList; What am I putting inside the angle brack...

Difference between std::tr1::array and boost::array

I was under the impression that std::tr1::array was the same as the boost::array in that it would throw an exception when accessing an index out of bounds. In fact, I took a peek in the header and it appears that way as well. Could someone explain why the following code results in a bus error (gcc version 4.0.1 (Apple Inc. build 5465)) ...

Namespace Aliasing in C++

It is widely known that adding declarations/definitions to namespace std results in undefined behavior. The only exception to this rule is for template specializations. What about the following "hack"? #include <iostream> namespace std_ { void Foo() { std::clog << "Hello World!" << std::endl; } using namespace std; } int...

Passing std::string in a library API

We are currently building an API for a certain library. Part of the interface requires the library to get and return to the user classes such as vector and string. When trying to simulate use of the library in a simple scenario, in debug mode the system crush when delivering a string as an input. I believe there is a different represen...