c++

Version of STL optimized for compile time?

Hi! I'm looking for a variant of the STL (it's okay if it doesn't have all the functionality) that's optimized for short compile times -- I get bothered by long compile times that delay my compile-debug-edit cycle. I'm mainly interested in the containers of the STL: vector/map, and not so much the algorithms. Thanks! ...

Custom byte size?

So, you know how the primitive of type char has the size of 1 byte? How would I make a primitive with a custom size? So like instead of an in int with the size of 4 bytes I make one with size of lets say 16. Is there a way to do this? Is there a way around it? ...

Is it bad practice to use multi-dimensional arrays in C/C++?

Some programmers seem to violently hate them, while others seem to think they're fine. I know that anything that can be done to a multi-dimensional array can also be done to a regular array, so they're functionally equivalent. Is it bad practice to use multi-dimensional arrays, or does it not matter? ...

using pthread in c++

I am using pthread.h in a *.cc file. when I try to use pthread_exit(0); or pthread_join(mythrds[yy],NULL); it says : .cc:(.text+0x3e): undefined reference to `pthread_exit' when complied very similar code in a *.c file with gcc it work perfect. How Can I use pthread's in c++.. (I also added -lpthread) .. void *myThreads ( void *ptr ) ...

C++ unicode UTF-16 encoding

Hi all, I have a wide char string is L"hao123--我的上网主页", and it must be encoded to "hao123--\u6211\u7684\u4E0A\u7F51\u4E3B\u9875". I was told that the encoded string is a special “%uNNNN” format for encoding Unicode UTF-16 code points. In this website(http://rishida.net/tools/conversion/), it tell me it's JavaScript escapes. Bu...

boost::shared_ptr in Objective-C++

This is a better understanding of a question I had earlier. I have the following Objective-C++ object @interface OCPP { MyCppobj * cppobj; } @end @implementation OCPP -(OCPP *) init { cppobj = new MyCppobj; } @end Then I create a completely differently obj which needs to use cppobj in a boost::shared_ptr (I have no choic...

C++ Event (Focus) Handling

Due to comments I added the following code (in BasicPanel) Connect(CTRL_ONE, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_TWO,wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_THREE, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_FOUR, ...

C++ - Conway's Game of Life & Stepping Backwards

EDIT #2 - I'm done the previous state part. Now I need to my state algorithm so that the grid acts like a Toroidal Array. That is, the top/bottom and right/left edges wrap around. Not sure how to do this, though. How would I change the nested-if's in thisTimer() to do this? EDIT - Is the serialising really necessary? I see how it cou...

Finding if all elements in a vector<string> are in a string

I have a vector and I need to see if all the strings in that vector are substrings of another given string. eg vector<string> v; v.push_back("str1"); v.push_back("str2"); string s1 = "str1, str2, str3"; string s2 = "str1, str3"; Is there a way to get true from s1 and false from s2 without looping over the vector? Also, note that due...

Is it safe to call a function to intialize a class in a ctor list?

I have Angle class that I want initialized to a random value. The Angle constructor can accept an int from a random() function. Is it safe to place this call in the ctor list: foo::foo() : Angle(random(0xFFFF)) {...} or do I have to do it in the body of the constructor? foo::foo() { Angle = Angle(random(0xFFFF)); ...} If it matte...

path settup method

When we set the path on source code sometimes we use "\\" or "\"and sometimes we use "/".. What's the environment dependency between them? ...

Passing Derived Class Instances as void* to Generic Callbacks in C++

This is a bit of an involved problem, so I'll do the best I can to explain what's going on. If I miss something, please tell me so I can clarify. We have a callback system where on one side a module or application provides a "Service" and clients can perform actions with this Service (A very rudimentary IPC, basically). For future refer...

Does gcc's STL support rvalue references now?

I know Visual Studio 2010's standard library has been rewritten to support rvalue references, which boosts its performance considerably. Does the standard library implementation of gcc 4.4 (and above) support rvalue references? ...

How is inheritance implemented at the memory level?

Suppose I have class A { public: void print(){cout<<"A"; }}; class B: public A { public: void print(){cout<<"B"; }}; class C: public A { }; How is inheritance implemented at the memory level? Does C copy print() code to itself or does it have a pointer to the it that points somewhere in A p...

.so build error coming - please suggest (eclipse CDT cygwin)

Build of configuration Debug for project myso ** make all filename.d:1: * multiple target patterns. Stop. The makefile looks like: # All Target all: libmyso.so # Tool invocations libmyso.so: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' @echo 'Invoking: GCC C++ Linker' g++ -L"E:\cygwin\lib" -shared -o"libmyso.so" ...

strange redefined symbols

...

How do you run your unit tests? Compiler flags? Static libraries?

I'm just getting started with TDD and am curious as to what approaches others take to run their tests. For reference, I am using the google testing framework, but I believe the question is applicable to most other testing frameworks and to languages other than C/C++. My general approach so far has been to do one of three things: Write...

Can i Convert VB code to C++ code

Can I convert my VB code to C++? How can I do it? This is my VB code: Dim OpenFileDialog1 As New OpenFileDialog With OpenFileDialog1 .CheckFileExists = True .ShowReadOnly = False .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg" .FilterIndex = 2 If .ShowDialog = DialogResult.OK Then ' Load the sp...

memcpy(), what should the value of the size parameter be?

Hi, I want to copy an int array to another int array. They use the same define for length so they'll always be of the same length. What are the pros/cons of the following two alternatives of the size parameter to memcpy()? memcpy(dst, src, ARRAY_LENGTH*sizeof(int)); or memcpy(dst, src, sizeof(dst)); Will the second option always ...

Visual Studio "go to header file" not working with hpp files

The very handy right click menu option "Go To Header File" in Visual Studio 2005 doesn't seem to work if my header file is an .hpp file for that module; I've deleted/rebuilt the intellisense file but it still doesn't want to know. Is there a setting or something somewhere to do this? ...