For some reason I thought C++0x allowed std::initializer_list as function argument for functions that expect types that can be constructed from such, for example std::vector. But apparently, it does not work. Is this just my compiler, or will this never work? Is it because of potential overload resolution problems?
#include <string>
#in...
I already wrote here about the http chat server I want to create: http://stackoverflow.com/questions/2352220/alternative-http-port
This http server should stream text to every user in the same chat room on the website. The browser will stay connected and wait for further html code. (yes that works, the browser won't reject the connection...
While doing Windows Mobile development, which language should I use? C# or C++ or something else? Why one is better than others?
...
I've always been taught that if an integer is larger than a char, you must solve the byte ordering problem. Usually, I'll just wrap it in the hton[l|s] and convert it back with ntoh[l|s]. But I'm confused why this doesn't apply to single byte characters.
I'm sick of wondering why this is, and would love for a seasoned networks programme...
I was asked the following question at a recent job interview:
What do you think is the main theme / single word that sums up the Effective C++ series from Scott Meyers?
What would be your answer to this question?
...
In scripting languages like PHP having a for loop like this would be a very bad idea:
string s("ABCDEFG");
int i;
for( i = 0; i < s.length(); i ++ )
{
cout << s[ i ];
}
This is an example, i'm not building a program like this. (For the guys that feel like they have to tell me why this piece of code <insert bad thing about it here>)...
Trying to make a Fraps type program. See comment for where it fails.
#include "precompiled.h"
typedef IDirect3D9* (STDMETHODCALLTYPE* Direct3DCreate9_t)(UINT SDKVersion);
Direct3DCreate9_t RealDirect3DCreate9 = NULL;
typedef HRESULT (STDMETHODCALLTYPE* CreateDevice_t)(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
DWORD B...
I have derived and simplified an equation in Matlab and want to use it in a c++ program. Matlab likes to use powers, the ^ sign but c++ doesn't like it one bit. How can i get Matlab to rewrite the equation so that it outputs a c++ friendly equation?
...
I am writing an embedded app. In some places, I use std::ostringstream a lot, since it is very convenient for my purposes. However, I just discovered that the performance hit is extreme since adding data to the stream results in a lot of calls to malloc and free. Is there any way to avoid it?
My first thought was making the ostringstrea...
I need an STL-like bidirectional iterator (operator<, begin(), rbegin(), end(), rend()) as an inner class to the following (I already spent considerable time all by myself to put together a working tree from a C# article in J of Object Tech and translated it to C++):
template<typename K, typename V> class rbtree {
public:
rbtree()...
Hi,
I have a requirement where in i have a set of classes and they have a one on one correspondence with another set of classes. Consider something like this
a)
template < class A >
class Walkers
{
int walk( Context< A >* context );
};
The set of Context classes are not templates. They are individual classes. I need to cre...
Hi
Does anybody know how to register my custom exception translator when using auto test cases in Boost.Test? I've found some examples (very few actually), but they do not show how to use this feature with auto test cases which are the biggest advantage of boost.test in my opinion. My example test suite:
#define BOOST_TEST_MODULE S...
As I mentioned in my yesterday's post, I'm trying to teach myself templates from the book: Templates: The Complete Guide. And although I'm finding this book very nicely presented and material there is explained really well there are no exercises attached after each chapter to test your knowledge, like it is in The C++ Language by B.S for...
I have a class that spawns an arbitrary number of worker object that compute their results into a std::vector. I'm going to remove some of the worker objects at certain points but I'd like to keep their results in a certain ordering only known to the class that spawned them. Thus I'm providing the vectors for the output in the class A.
...
Solution:
This is an interesting problem, because sometimes we have no choice but to declare an explicitly qualified name.
std::string convert();
namespace tools {
class Numeric {
// ...
// parsed as: "friend std::string::convert ();"
// (actual name is missing!).
friend std::string ::convert();
};
}
In that c...
Which of the following two books are better in your opinion:
Effective C++: 55 Specific Ways to Improve Your Programs and Designs by Scott Meyers
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices by Herb Sutter & Andrei Alexandrescu.
I have heard good things about both books, but I don't have the time to read both. Whi...
Hi,
Can someone suggest me a way to map a template classes with a set of member functions from another class? Whenever i call one of the function inside a template class, it should call the associated member function of the other class.
Updating with a use-case
template<int walktype>
class Walker
{
Node* node;
bool walk()
...
When creating a C++ inheritance structure, you have to define member functions exactly the same in multiple places:
If B is an abstract base class, and D, E, and F all inherit from B, you might have this:
class B
{
virtual func A( ... params ) = 0;
};
class D : public B
{
func A( ... params );
};
/* ... etc... similar implement...
Possible Duplicate:
The Hostname Regex
I'm trying to use pcrepp (PCRE) to extract hostname from url.
the pcre regular expression is as same as Perl 5 regular expression.
for example:
url = "http://www.pandora.com/#/volume/73";
// the match will be "http://www.pandora.com/".
I can't find the correct syntax of the regex for ...
If I use a class/method like the one described here how can I get the description/address of the call at the top of the stack?
Basically I want some value I can use in a call to our bug tracking system. I want to "uniquely" identify based on the address of the instruction that caused the exception.
(It is usually something of the form...