I'm sure that boost has some functions for doing this, but I don't know the relevant libraries well enough. I have a template class, which is pretty basic, except for one twist where I need to define a conditional type. Here is the psuedo code for what I want
struct PlaceHolder {};
template <typename T>
class C{
typedef (T == P...
Hi.
I'm having some trouble with a program using pthreads, where occassional crashes occur, that could be related to how the threads operate on data
So I have some basic questions about how to program using threads, and memory layout:
Assume that a public class function performs some operations on some strings, and returns the result ...
I've seen a few related posts, but I can't really make sense of what I need to do to fix a program I'm making for my entry-level C++ class.
My errors are:
Build Final Project of project Final Project with configuration Debug
Ld "build/Debug/Final Project" normal x86_64
cd "/Users/nick/Dropbox/|Syncs/Xcode/Final Project"
setenv MACOSX...
Hi Everyone,
I'm trying to write code that uses a member typedef of a template argument, but want to supply a default type if the template argument does not have that typedef. A simplified example I've tried is this:
struct DefaultType { DefaultType() { printf("Default "); } };
struct NonDefaultType { NonDefaultType() { print...
Recently, I was browsing through my copy of the C++ Pocket Reference from O'Reilly Media, and I was surprised when I came across a brief section and example regarding user-defined conversion for user-defined types:
#include <iostream>
class account {
private:
double balance;
public:
account (double b) { balanc...
I've a old C/C++ class that i want to refactor and access from .net using PInvoke
All P/Invoke tutorials refers to call win32 api but i haven't found anything to code the other side
Any tips/ideas ? my c/c++ experience is pretty rusty :(
UPDATE - this is for wrapping existing C/C++ code so it can called from .net using P/Invoke
How d...
I'm working on an algorithm to generate point to point linear gradients. I have a rough proof of concept implementation done:
GLuint OGLENGINEFUNCTIONS::CreateGradient( std::vector<ARGBCOLORF> &input,POINTFLOAT start, POINTFLOAT end, int width, int height,bool radial )
{
std::vector<POINT> pol;
std::vector<GLubyte> pdata(width *...
Hello.
While in other statements like if ... else you can avoid braces if there is only one instruction in a block, you cannot do that with try ... catch blocks: the compiler doesn't buy it. For instance:
try
do_something_risky();
catch (...)
std::cerr << "Blast!" << std::endl;
With the code above, g++ simply says it expects ...
Hi,
I have a program that I am sharing with a third party. I will be providing a bin executable to them. It is written in c++ but uses some c as well. they are suggesting that it needs to be c only. Do you guys think this will be a problem since I will be compiling and building it on a sparc station that will somewhat match their syste...
I want to use a precompiled library in my project.
I have 3 folders: Include (.h files), Lib (with .lib files) and Bin (with .dll files and .pdb files). I've never used precompiled libraries before (I hope this is the right term. correct me if I'm wrong). I want to use this API. How to add all this stuff to my project?
I use visual stud...
I'm implementing a simplistic JIT compiler in a VM I'm writing for fun (mostly to learn more about language design) and I'm getting some weird behavior, maybe someone can tell me why.
First I define a JIT "prototype" both for C and C++:
#ifdef __cplusplus
typedef void* (*_JIT_METHOD) (...);
#else
typedef (*_JIT_METHOD) ();
#en...
I came accross this:
t = Clamp(t/d, 0, 1)
but I'm not sure how to perform this operation on a vector. What are the steps to clamp a vector if one was writing their own vector implementation?
Thanks
clamp clamping a vector to a minimum and a maximum
ex:
pc = # the point you are coloring now
p0 = # start point
p1 = # end point
v...
I am writing a simple prototype code to demonstrate & profile I/O schemes (HDF4, HDF5, HDF5 using parallel IO, NetCDF, etc.) for a physics code. Since focus is on IO, the rest of the program is very simple:
class Grid
{
public:
floatArray x,y,z;
};
class MyModel
{
public:
MyModel(const int &nip1, const int &njp1, const int &nkp1,...
For example: the array
a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3
represents following table
a1, b1, c1, d1
a2, b2, c2, d2
a3, b3, c3, d3
now i like to bring the array into following form
a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3
Does an algorithm exist, which takes the array (from the first form) and the dimensions of ...
std::vector<double> C(4);
for(int i = 0; i < 1000;++i)
for(int j = 0; j < 2000; ++j)
{
C[0] = 1.0;
C[1] = 1.0;
C[2] = 1.0;
C[3] = 1.0;
}
is much faster than
for(int i = 0; i < 1000;++i)
for(int j = 0; j < 2000; ++j)
{
std::vector<double> C(4);
C[0] = 1.0;
C[1] = 1.0;
C[2] = 1.0;
C[3] = 1.0;
...
I downloaded the latest version of Boost and I'm trying to get the Boost.python tutorial up and running on Ubuntu 10.04: http://www.boost.org/doc/libs/1_43_0/libs/python/doc/tutorial/doc/html/python/hello.html
I navigated to the correct directory, ran "bjam" and it compiled using default settings. I did not yet create a bjam config file...
This might be a stupid question, but I notice that in a good number of APIs, a lot of method signatures that take integer parameters that aren't intended to be modified look like:
void method(int x);
rather than:
void method(const int &x);
To me, it looks like both of these would function exactly the same. (EDIT: apparently not in so...
Is there any way to send a key press to a DirectX application using Windows API without activating its window?
I know there is a solution for simple applications, but DirectX handles this quite different...
The solution is preferred in C++, and libraries are OK.
Thanks!
...
is it possible for me to intercept the text messages that get sent to my cellphone if i connect to my cellphone via bluetooth or USB or some other connection to my computer?
i want to create a database with all of my received text messages and be able to control my cell phone through my computer by using it to send text messages
i have...
I need a program to get the smaller of two numbers, and I'm wondering if using a standard "if x is less than y"
int a, b, low;
if (a < b) low = a;
else low = b;
is more or less efficient than this:
int a, b, low;
low = b + ((a - b) & ((a - b) >> 31));
(or the variation of putting int delta = a - b at the top and rerplacing instance...