I've been using the Concurrency Runtime in a C++ static library, and recently wanted to use this library in a C++/CLI project, to take advantage of the Windows Form designer and avoid MFC. Unfortunately, the Concurrency Runtime is not compatible with the /clr switch required in C++/CLI. I tried surrounding the included header files that ...
What is the C++ equivalent of PHP's is_dir() ?
http://www.php.net/manual/en/function.is-dir.php
bool is_dir ( string $filename )
Tells whether the given filename is a directory.
Working on a Linux platform only, what library would you use?
And what if cross-platform support mattered, what method would you use?
...
In one of my projects, I would like to have an auto-scrolling textbox.
I'm not talking of a textbox that scrolls whenever someone adds a text line, but of something which is like a movie "closing credits" sequence.
The textbox would be fullfiled with text and down-scroll slowly without any user action.
Is there any existing widget tha...
I get the following error:
error C2440: 'type cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'DWORD'
with
[
_Ty=LPCSTR ,
_Alloc=std::allocator<LPCSTR >
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be ca...
Given:
namespace A {
class Foo;
class Bar;
}
namespace A {
class Foo;
class Bar;
}
I want to template a class on the namespace A or B such that the following works:
template<name> class C {
name::Foo* foo;
name::Bar* bar;
}
Can this be done directly or do I need to create a pair of struct types with typedefs in them?
...
Background:
Big C++ MFC app that's not going to get rewritten any time soon. Few years ago needed to add features and decided that it would be easier built with C# and .NET so needed a way to call into .NET functions with the C++ app. At the time we were using VC6.0 for the MFC app and we built the .NET functionality using VS.NET 2...
Why does the following code not work
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
int main(){
string data;
int i=0;
while(i <= 5){
i++;
data += i;
data += "\n";
}
ofstream myfile;
myfile.open ("data.txt");
myfile <<...
I have some code that uses libgmp. At some point the user may request a factorial of a very large number. Unfortunately, this results in libgmp raising an abort signal.
For example the following code:
#include <cmath>
#include <gmp.h>
#include <iostream>
int main() {
mpz_t result;
mpz_init(result);
mpz_fac_ui(result, 209...
I'm trying to display a little square of solid color.
I've created a QGraphicsView widget myGraphicsView and call:
ui->myGraphicsView->setBackgroundBrush(QBrush(Qt::red, Qt::SolidPattern));
But it stays white. What am I doing wrong?
...
For most C++ projects Boost covers a lot of ground component wise but often used solutions and idioms require some boiler plate or ground work. What do you consider so essential that you would have it in every project and thus have it in a small "library"?
Some things I thought of:
Singleton base-class (somebody will think he needs it,...
I have a class which has a constructor that takes a const char*. It is:
c::c(const char* str) {
a = 32;
f = 0;
data = new char[strlen(str)];
memcpy(data, str, strlen(str));
}
And a function which takes one of them:
int foo(c& cinst);
You can call this function either by passing it an instance of a c:
c cinst("asdf"...
My boss wants me to write a simple RSS feed for an C++ MFC app that will pull and display information from the company's website. It also must be able to grab program updates from the website, tell the user that there are updates and then install the updates. Are there any tutorials that follow these guide lines? How would stackoverflow....
Does anybody know what ^Bo means at the beginning of a encoded string?
The rest of the string is valid ASCII.
Example: "^BoHello" should be interpreted as "Hello"
Note: '^B' is the control character 0x02
...
Let us assume we have a map class (unordered map, list, set, whatever will also do). We are looking for a specific element. After calling the find() member, we have to check with the end() member. But find() internally already knows whether it is returning a good iterator or the end iterator. Why should we need to call end() again? This ...
I need to store a list of various properties of an object. Property consists of a name and data, which can be of any datatype.
I know I can make a class "Property", and extend it with different PropertySubClasses which only differ with the datatype they are storing, but it does not feel right.
class Property
{
Property(std::string...
Hello. I'm trying to call a signal after an booost::asio::async_read from inside
a function called by boost::asio::io_service. The run function runs
in a thread, and the observers are connected in a different thread.
This is causing errors. It's my program or it's not possible to invoke a handler
that is running in another thread from i...
Why does the following code not work?
#include <iostream>
#include <string>
int main(){
char filename[20];
cout << "Type in the filename: ";
cin >> filename;
strcat(filename, '.txt');
cout << filename;
}
It should concatenate ".txt" on the end of whatever filename is inputted
Also, when I try to compile it (with g...
I have an scons project that force includes several header files as a compiler flag.
# Forced include files passed directly to the compiler
env.Append(CCFLAGS = ['/FIinclude.h'])
These files are not included by any files in the project. I need to add an explicit dependency for them.
forced_include_headers = ['include.h']
# Trying ...
Is there anything approximating Haskell's all or any functions as part of the STL? If not, is the below a good implementation (I noticed the sgi STL performed partial specialization if the iterators were random access, though I have not bothered with this)?
template <typename InputIterator, typename Predicate>
inline bool all(InputIter...