I'm still having issues justifying TDD to myself. As I have mentioned in other questions, 90% of the code I write does absolutely nothing but
Call some Windows API functions and
Print out the data returned from said functions.
The time spent coming up with the fake data that the code needs to process under TDD is incredible -- I lite...
I observed some inconsistency between two compilers (g++ 4.5, VS2010 RC) in the way they match lambdas with partial specializations of class templates. I was trying to implement something like boost::function_types for lambdas to extract type traits. Check this for more details.
In g++ 4.5, the type of the operator() of a lambda appears...
I'm considering picking up some very rudimentary understanding of assembly. My current goal is simple: VERY BASIC understanding of GCC assembler output when compiling C/C++ with the -S switch for x86/x86-64.
Just enough to do simple things such as looking at a single function and verifying whether GCC optimizes away things I expect to d...
Erm. I hope I am seriously overlooking something.
I want to rotate a 2d vector (kartesian) v by a certain angle phi.
I can't find a function that generates the appropriate matrix
or just performs that function.
I know how to do this by hand. I am looking for a ublas utility "something"
that does this for me.
...
If you use stl containers together with reference_wrappers of POD types, code such as the following works just fine:
int i = 0;
std::vector< boost::reference_wrapper<int> > is;
is.push_back(boost::ref(i));
std::cout << (std::find(is.begin(),is.end(),i)!=is.end()) << std::endl;
However, if you use non-POD types like (contrived example)...
I'm trying to put together a simple program that will let me visualize a series of consecutive cuts on a wood panel using a router with a particular cutting head. I'm trying to find a decent geometry library that will give me a shortcut through the CAD-like stuff.
Specifically, I'd like to be able to define a rectangular solid (the w...
okay,
I am writing a matrix class and have overloaded the function call operator twice. The core of the matrix is a 2D double array. I am using the MinGW GCC compiler called from a windows console.
the first overload is meant to return a double from the array (for viewing an element).
the second overload is meant to return a reference ...
Due to how Microsoft implements the heap in their non-DLL versions of the runtime, returning a C++ object from a DLL can cause problems:
// dll.h
DLL_EXPORT std::string somefunc();
and:
// app.c - not part of DLL but in the main executable
void doit()
{
std::string str(somefunc());
}
The above code runs fine provided both the D...
Update 2:
Well I’ve refactored the work-around that I have into a separate function. This way, while it’s still not ideal (especially since I have to free outside the function the memory that is allocated inside the function), it does afford the ability to use it a little more generally. I’m still hoping for a more optimal and elegant s...
I need to work with a binary number.
I tried writing:
const x = 00010000 ;
But it didn't work.
I know that I can use an hexadecimal number that has the same value as 00010000 but I want to know if there is a type in C++ for binary numbers & if there isn't, is there another solution for my problem?
...
Hi there, I've been trying to get back into coding for a while, so I figured I'd start with some simple SDL, now, without the file i/o, this compiles fine, but when I throw in the stdio code, it starts throwing errors. This I'm not sure about, I don't see any problem with the code itself, however, like I said, I might as well be a newbie...
what am I doing wrong here? I keep on getting a compilation error when I try to run this in codelab (turings craft)
Instructions:
Write the implementation (.cpp file) of the GasTank class of the previous exercise. The full specification of the class is:
A data member named amount of type double.
A constructor that no parameters. Th...
There are two major refactoring tools which can be installed for Visual Studio that provide C++ support. The full versions of both tools are $250, and they seem to offer similar functionality. They are:
Developer Express' Refactor Pro + CodeRush
Whole Tomato's Visual Assist X
Which tool is better?
EDIT: My initial evaluation of the ...
Hi All,
I have a bunch of projects that all could share a "common" static library of classes.
What confuses me is if I make a static library out of these classes and link against it in my projects that I still need the headers of the classes in the static library in my main projects.
What is the benefit of the static library then?
H...
In C++, I can change the operator on a specific class by doing something like this:
MyClass::operator==/*Or some other operator such as =, >, etc.*/(Const MyClass rhs) {
/* Do Stuff*/;
}
But with there being no classes (built in by default) in C. So, how could I do operator overloading for just general functions?
For example, if...
The following code gives an error when it's supposed to output just std::endl:
#include <iostream>
#include <sstream>
struct MyStream {
std::ostream* out_;
MyStream(std::ostream* out) : out_(out) {}
std::ostream& operator<<(const std::string& s) {
(*out_) << s;
return *out_;
}
};
template<class OutputStream>
struct Foo...
i need to find a way how to find the address's for value of another program. i find the address before hand but i don't know how to find them again after i close and reopen the program with out searching for them again (i need the program to find them on it's own).
anyone know how i can do this (sorry if im unclear i don't know how to ex...
Hi all,
Im wondering something.
I have class Polygon, which composes a vector of Line (another class here)
class Polygon
{
std::vector<Line> lines;
public:
const_iterator begin() const;
const_iterator end() const;
}
On the other hand, I have a function, that calculates a vector of pointers to lines, and based on those lines...
I've got a pointer to a string, (char *) as input. The date/time looks like this:
Sat, 10 Apr 2010 19:30:00
I'm only interested in the date, not the time.
I created an "input_facet" with the format I want:
boost::date_time::date_input_facet inFmt("%a %d %b %Y");
but I'm not sure what to do with it. Ultimately I'd like to create a date...
Hi all,
I am trying to install the python wrapper for the ANN (approx near neighbors) c++ library: link is http://www.scipy.org/scipy/scikits/wiki/AnnWrapper . I am on Windows 7 32-bit.
Unfortunately the documentation is a bit terse and I am a newbie to programming in general, so I cannot decipher the instructions found within. I hav...