This question also applies to boost::function and std::tr1::function.
std::function is not equality comparable:
#include <functional>
void foo() { }
int main() {
std::function<void()> f(foo), g(foo);
bool are_equal(f == g); // Error: f and g are not equality comparable
}
The operator== and operator!= overloads are declared ...
Hi,
I have to process very large log files (hundreds of Gigabytes) and in order to speed things up I want to split that processing on all the cores I have available. Using seekg and tellg I'm able to estimate the block sizes in relatively small files and position each thread on the beginning of these blocks but when they grow big the in...
I'm looking for an alternative to SDL that supports multiple windows on multiple display devices for OpenGL.
Is there any mature library that provides this?
I'm aware taht SDL 1.3 will support this but it seems that's a bit into the future.
...
I can fill a TreeView control with particular Registry keys by enumerating registry keys recursively and put them in the TreeView control; then for performance reason, I attempt to
use a nonrecursive/iterative approach to enumerate registry keys, but how can I fill the TreeView since a "tree" is naturally recursive (at least, in my under...
Hi Experts,
I am trying to create GtkDialog with system wide Modal property i.e. when the dialog is opened no other window should get focus. There is an option for making it modal using GtkDialogFlag but that is not system wide modal.
Please I need your help urgently.
Kind Regards,
-Durgesh O Mishra
...
I am using a std::set<int> for the key of a std map (std::unordered_map<std::Set<int>,float>). I need a hash for this set.
The set will always be only two integers, whose values could be up to 2 million.
Any ideas on a good and fast hash for such a key as performance is critical?
...
So original SLN compiled. I tried it, it worked. But when I am triing to compile it under \clr (which is critical for me). So what I tried was to try playing with compiler options but after fixing general visiable errors I ended with this 3
Error 10 error LNK2028: unresolved token (0A0003BF) "extern "C" int __cdecl _CrtDbgReportW(in...
Hi.
When I exit my C++ program it crashes with errors like:
EAccessViolation with mesage 'Access violation at address 0...
and
Abnormal Program Termination
It is probably caused by some destructor because it happens only when the application exits. I use a few external libraries and cannot find the code that causes it. Is there a f...
I have searched Google and Stackoverflow for this question, but I still don't understand how a minimax function works.
I found the wikipedia entry has a pseudocode version of the function:
function integer minimax(node, depth)
if node is a terminal node or depth <= 0:
return the heuristic value of node
α = -∞
for ch...
I'm working on a project in C++/CLI, which includes some custom-made native libraries, a pair of custom .NET components and many .NET application with Windows Forms.
Right now, I have problem with the Visual Studio designer; each time I add one of our custom components into a form it works, but after closing the designer tab it fails to...
I came from Java/C# and am amazed at the sheer ugliness of strings in C++, particularly the variety of C++ types invented to make strings more pleasant that all still seem to be in use somewhere (std::string std::wstring CString null terminated strings, null terminated strings of tchars, ....) and whose interoperability and encodings onl...
c++ function, strtok() cplusplus.com
Will this example suffer from buffer overrun if str is not terminated properly?
/* strtok example */
/* source - cplusplus.com (see link below) */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] ="- This, a sample string.";
char * pch;
printf ("Splitting string \"%s\" into tok...
I work on a third party language product which does dynamic binding via ODBC and a customer is wanting to be able to insert bound variables without a field list, i.e. INSERT INTO table VALUES (values), not INSERT INTO table (columns) VALUES (values). The problem is that in the former case for SQLServer bind variables, the AUTO_INCREMENT...
I'm working on some code that compiles and links (and even has released commercial products) on Windows using MSVC. It doesn't compile with GCC though, I get the following errors:
.../CBaseValue.h: In member function 'bool CBaseValue::InstanceOf()':
.../CBaseValue.h:90:18: error: invalid use of incomplete type 'struct CValueType'
.../CB...
I need to read exactly 32 bits from a file. I'm using ifstream in the STL. Can I just directly say:
int32 my_int;
std::ifstream my_stream;
my_stream.open("my_file.txt",std::ifstream::in);
if (my_stream && !my_stream.eof())
my_stream >> my_int;
...or do I need to somehow override the >> operator to work with int32? I don't see t...
Consider this code:
template <int N>
struct X
{
friend void f(X *) {}
};
int main()
{
f((X<0> *)0); // Error?
}
compilers seem to heavily disagree. (MSVC08/10 says no, GCC<4.5 says yes, but 4.5 says no, sun 5.1 says yes, intel 11.1 says yes too but comeau says no (both are EDG)).
According to "C++ Templates - The complete guide": ...
I am using the dot language to create a graph using Boost. My Graphs are huge and I am trying to delete graphs that are no longer used.
Under boost/graph/graphviz.hpp
I added a function to remove a vertex:
virtual void
do_remove_vertex( const node_t& node)
{
bgl_vertex_t v = bgl_nodes[node];
clear_vertex(v,graph_);
...
Hey guys.Tomorrow I have a phone interview with a good company for a Junior Software Engineer position. I have been out of the university with a bachelors for 3 months now, and am a bit rusty on my C++, as it has been a few semesters since I worked with it. I am currently reviewing it (working on pointers at the moment) to be prepared fo...
Hell-o all, Im new to qt and I am having trouble drawing one single point.
I have a big qMainWindow that eventually calls a QgraphicsScene and inside of it I need to draw a single point, one little pixel, that is all I want, I want to use a QPainter but Im having trouble instantiating one. Any ideas??
...
Let's say I have an Image class and I want to provide some operations on the image, like scaling, rotating etc.
I want to provide 2 types of functions for each operation. One that modifies the object and other that does not.
In Ruby, there are functions that end in ! and indicate that this one is going to modify the argument.
Since this...