c++

Odd C++ member function declaration syntax: && qualifier.

From Boost::Thread: template <typename R> class shared_future { ... // move support shared_future(shared_future && other); shared_future(unique_future<R> && other); shared_future& operator=(shared_future && other); shared_future& operator=(unique_future<R> && other); ... } What on earth are those double-ampersands ? I went over "BS Th...

Float Values as an index in an Array in C++

Can a float value be used as the index of an array? What will happen if an expression used as an index resulted to a float value? ...

I get error LNK2001 in TeamCity but not in Vs 2005...

Hi All, I currently have a solution in VS 2005 which I attempted to trim down as it currently contains 150+ projects. As I don't know the solution that well, I am looking at set info, such as the references and the project dependencies within the solution.. In doing so, I have been able to remove approx 15-20 projects from the solution ...

Why is it not possible to store a function pointer of a base class?

The following code gives an compilation error for void b() { m = &A::a; }; stating that A::a() is protected. (Which it is - but that should be no problem) However the compiler doesn't care when I write B::a(). Even though both mean the same I would prefer A::a() because it states explicitely that a() is defined in A. So what is the reas...

Remove last character from C++ string

Hi! How can I remove last character from a C++ string? I tried st = substr(st.length()-1); But it didn't work. ...

Maximum number of characters in a string

Is there a maximum number of characters allowed in a string? If so, what is the limit on the number of characters? ...

deriving a templated class in c++

I have a templated base class which follows: template<class scalar_type, template<typename > class functor> class convex_opt{ .. }; How to derive a class from this templated class? ...

Dynamic Memory Allocation

What are the advantages of using dynamic memory allocation to create an array compared to the ordinary allocation of elements in an array? ...

Select from SQLite with Qt

I try to deal with SQLite database on Qt 4.5.3 on Linux. I've already created DB with another program and it looks like this: screenshot Then, I try to perform select on Qt: db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(filename); // Here is FULL path to the database. I've checked it twice :) bool ok = db.open(); qDebug...

Instruction-Level-Parallelism Exploration

Hi all, I am just wondering if there are any usefuls tools out there that allow me to exploit the Instruction-Level-Parallelism in some algorithms. More specifically, I have a subset of algorithms from the multimedia domain and I wonder what is the best way to exploit ILP in this algorithms. All this algorithms are implemented in C, so ...

std::stringstream and std::ios::binary

I want to write to a std::stringstream without any transformation of, say line endings. I have the following code: void decrypt(std::istream& input, std::ostream& output) { while (input.good()) { char c = input.get() c ^= mask; output.put(c); if (output.bad()) { throw std::ru...

What is the importance of invoking base class constructor explicitly?

class A { A() { } }; class B : public A { B() : A() { } }; Why do we need to call the base class's constructor explicitly inside B's constructor? Isn't it implicit? ...

Boost.Bind to access std::map elements in std::for_each

I've got a map that stores a simple struct with a key. The struct has two member functions, one is const the other not. I've managed calling the const function using std::for_each without any problems, but I've got some problems calling the non-const function. struct MyStruct { void someConstFunction() const; void someFunction(); };...

(C++) How to insert pair into map

I have the following map structure: map < pair < int,int >, object* > and I wish to insert into it. How would I do it since I am trying to insert a pair and an object and I must make a pair out of this. Should I create a new pair using make_pair() out of the pair and object that I have? If so, could you please let me know how to do this?...

Linking FriendlyNames from the Registry to drive letters for USB storage devices

I am writing an application that allows Syncing to USB storage devices and I would like to display the FriendlyName for the devices that can be found in the registry at HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR\ I am using GetLogicalDrives to get the list of available devices, GetDriveType to filter by DRIVE_REMOVABLE and GetVolumeInfo...

String statements

Talking about strings in C++, what is the difference between the following statements: s1=s2 and strcpy (s1, s2)? Supposing that s1 and s2 are (original version: type 'char', as revised) type char *. ...

template specialization for CPPUnit isn't being used

If you've used CPPUnit before, you are probably aware of its assertion_traits class that is templatized to handle arbitrary types. This is what allows it to print the "actual" and "expected" values for non-string types when test cases fail. I have used this with success several times, but for one specific type it isn't working for me. ...

C++ class for arrays with arbitrary indices

Do any of the popular C++ libraries have a class (or classes) that allow the developer to use arrays with arbitrary indices without sacrificing speed ? To give this question more concrete form, I would like the possibility to write code similar to the below: //An array with indices in [-5,6) ArbitraryIndicesArray<int> a = ArbitraryIndi...

Multiassignment in VB like in C-Style languages

Is there a way to perform this in VB.NET like in the C-Style languages: struct Thickness { double _Left; double _Right; double _Top; double _Bottom; public Thickness(double uniformLength) { this._Left = this._Right = this._Top = this._Bottom = uniformLength; } } ...

C++ libpthread program segfaults for unknown reason

Hi I have a libpthread linked application. The core of the application are two FIFOs shared by four threads ( two threads per one FIFO that is ;). The FIFO class is synchronized using pthread mutexes and it stores pointers to big classes ( containing buffers of about 4kb size ) allocated inside static memory using overloaded new and del...