I want to test if a number double x is an integer power of 10. I could perhaps use cmath's log10 and then test if x == (int) x?
edit: Actually, my solution does not work because doubles can be very big, much bigger than int, and also very small, like fractions.
...
I am trying to write an std::iterator for the CArray<Type,ArgType> MFC class. This is what I have done till now:
template <class Type, class ArgType>
class CArrayIterator : public std::iterator<std::random_access_iterator_tag, ArgType>
{
public:
CArrayIterator(CArray<Type,ArgType>& array_in, int index_in = 0)
: m_pArray(&arr...
I have J2EE application deployed on JBoss AS. There is a EJB3 stateless session bean in this app.
I need to write dll that will wrap the methods of that stateless session bean. There will be just standard data types as arguments, so I don't need to pass some specific objects as an arguments.
Is that possible?
...
Assuming I have 2 STL vectors:
vector<int> a;
vector<int> b;
Let's also say the both have around 30 elements.
How do I add the vector b to the end of vector a?
The dirty way would be iterating through b and adding each element via push_back, though I wouldn't like to do that!
...
Hello there,
I tried to unzip a binary file to a membuf from a zip archive using Lucian Wischik's Zip Utils:
http://www.wischik.com/lu/programmer/zip_utils.html
http://www.codeproject.com/KB/files/zip_utils.aspx
FindZipItem(hz, filename.c_str(), true, &j, &ze);
char *content = new char[ze.unc_size];
UnzipItem(hz, j, content, ze.unc_s...
i need to serialize directory tree.
i have no trouble with this type:
std::map<
std::string, // string(path name)
std::vector<std::string> // string array(file names in the path)
> tree;
but for the serialization the directory tree with the content i need other type:
std::map<
std::string, // string(path name)
std::vector...
I want to have something similar to map but while iterating I want them to be in the same order as it is added.
Example
map.insert("one", 1);
map.insert("two", 2);
map.insert("three", 3);
While iterating I want the items to be like "one", ""two", "three"..By default, map doesn't provide this added order. How to get the map elements t...
I have looked into the binaries produced by MSVC 2010 from my source code, and saw everything being filled with "junk". (Not the kind of junk that calls itself "my code")
I don't know how to explain, but my executables are being added too much unnecessary information, like:
Lots of Microsoft default error messages, I don't want them
X...
In the spirit of Go-language, where simpler syntax is considered pretty important, here's a proposal for simpler array declaration in C++:
int value;
int_1 list;
int_2 table;
int_3 cube;
RECT rect;
RECT_1 rects;
Using typedefs this can expand to:
int value;
vector<int> list;
vector<vector<int> > table;
vector<vector<vector<int> ...
Is there a way to generate a c++ header file for an .obj file? Or perhaps is there an utility that can view .obj files. I've already found objconv that converts between formats, but I can't find any .h generator/viewer.
...
I have to load an array of doubles from a file, multiply each element by a value in a table (different values for different elements), do some work on it, invert the multiplication (that is, divide) and then save the data back to file.
Currently I implement the multiplication and division process in two separate methods. Now there is so...
I'm trying to use a pre-compiled library provided as a .so file.
This file is dynamically linked against a few librairies :
$ ldd /usr/local/test/lib/libtest.so
linux-gate.so.1 => (0xb770d000)
libstdc++-libc6.1-1.so.2 => not found
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb75e1000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7499000)
/l...
Previously I've written some very simple multithreaded code, and I've always been aware that at any time there could be a context switch right in the middle of what I'm doing, so I've always guarded access the shared variables through a CCriticalSection class that enters the critical section on construction and leaves it on destruction. ...
How can I find the user's home directory in a cross platform manner in C++? i.e. /home/user in Linux, C:\Users\user\ on Windows Vista, C:\Documents And Settings\user\ on Windows XP, and whatever it is that Macs use. (I think it's /User/user)
Basically, what I'm looking for is a C++ way of doing this (example in python)
os.path.expandus...
HI Folks,
I have a threaded C++ program where up to three threads are calling select on a three separate socket descriptors waiting for data to become available. Each thread handles one socket and adds it to the readfds with a timeout of 300 seconds. After select returns if there is data available I'm calling recv to read it.
Is ther...
My code has an interface like
class IExample { ~IExample(); //pure virtual methods ...};
a class inheriting the interface like
class CExample : public IExample { protected: CExample(); //implementation of pure virtual methods ... };
and a global function to create object of this class -
createExample( IExample *& obj ) { obj = new ...
This question, asked this morning, made me wonder which features you think are missing from the C++ Standard Library, and how you have gone about filling the gaps with wrapper functions. For example, my own utility library has this function for vector append:
template <class T>
std::vector<T> & operator += ( std::vector<T> & v1,
...
I have a C++ class I want to inspect. So, I would like to all methods print their parameters and the return, just before getting out.
The latter looks somewhat easy. If I do return() for everything, a macro
#define return(a) cout << (a) << endl; return (a)
would do it (might be wrong) if I padronize all returns to parenthesized (or w...
I have a parametric curve, say two vectors of doubles where the parameter is the index, and I have to calculate the angle of the tangent to this curve at any given point (index).
Any suggestion or link about how to do that?
Thanks.
...
Say you see a loop like this one:
for(int i=0;
i<thing.getParent().getObjectModel().getElements(SOME_TYPE).count();
++i)
{
thing.getData().insert(
thing.GetData().Count(),
thing.getParent().getObjectModel().getElements(SOME_TYPE)[i].getName()
);
}
if this was Java I'd probably not think twice. But in performance-...