c++

How To Determine What Input Bus Is Active When AUEffectBase::Render Is Called?

It's clearly a n00b question, as this has been implemented successfully in applications. But it's 2009 and I'm still unclear how input/output buses work with AUBase. I'll crib the wording of my question from a post to the coreaudio-api mailing list. This question pops up other times with no answer through 2005. I was just looking ...

C++ template parameter in array dimension

I have have the following code using templates and array dimension as template non-type parameter template<int n> double f(double c[n]); ... double c[5]; f<5>(c); // compiles f(c); // does not compile should not the compiler to be able to instantiate the second f without explicit template parameter? I am using g++4.1 thanks ...

Load multiple copies of a shared library

I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures). For performance reasons, I do not want to simply wrap the function calls in a mutex. What I would like to do is to spawn, say 4 threads, and also...

Casting UINT64 to float?

Is it safe to cast a UINT64 to a float? I realize that UINT64 does not hold decimals, so my float will be whole numbers. However, my function to return my delta-time returns a UINT64, which isn't a very useful type for the function I'm currently working with. I'm assuming a simple static_cast<float>(uint64value) will not work? ...

How do I "normalize" a pathname using boost::filesystem?

We are using boost::filesystem in our application. I have a 'full' path that is constructed by concatenating several paths together: #include <boost/filesystem/operations.hpp> #include <iostream>   namespace bf = boost::filesystem; int main() { bf::path root("c:\\some\\deep\\application\\folder"); bf::path subdir("..\\conf...

How to have templated function overloads accept derived classes from different base classes?

I want to be able to define template <class TX> void f(const TX &x){ ... } template <class TY> void f(const TY &x){ ... } where TX must be derived from BaseX and TY must be derived from BaseY (how do I specify this kind of thing?), and I want to be able to call it as f(DerivedX<T>()) It is most important that I can avoid specifying...

Traversing/Setting L and RChild index's in complete Binary Heap C++

Hello, I used a binary heap concept to insert elements in my items array: void BST::insert(const data &aData) { int slot = size + 1; if ( size >= maxSize ) this->reallocate(); while ( slot > 1 && aData < items[slot / 2 - 1].theData ) { items[slot - 1] = items[slot / 2 - 1]; slot = slot / 2; } ...

What's A QT Or Open Source C++ Template For Ordinal Sorting

Hi, I am looking for a special template class, hopefully either a QT template or a self-contained open source library. This template class is intended to act as a container for a set of objects. Each object in the set has an integer-valued weight function but the weight function itself is arbitrary. It could range uniformly from 10 to ...

[Vector] Iterator and 2d vector

vector< vector<int> >::iterator temp = mincost.end(); vector<int> a = *temp; if ( *temp != *(temp--) ) return 0; mincost is a 2d vector, I want to get the last vector<int> of this vector and last--. I don't really understand about iterator :) . Help me !! :D Thx ^^ ...

middle of linked list

how to find the middle of the linked list when we are not informed of its size and it must be performed using only one loop and only one pointer. ...

XSelectInput -- keypressed/keyreleased events not firing

I have the following code. For some reason the key-related events aren't firing. FocusChanged is firing fine. I'm using Gnome. Could it be that Gnome's intercepting these and not passing them through? I mean, some people may regard this as a security risk (keylogger), so it's a possibility. void PluginKeyboard::PluginPoll() { Displa...

Outputting from file one line at a time

I'm trying to output text from a file one line at a time. I'm currently hardcoding it and I have this so far: int main(int argc, char *argv[]) { int x; int k; int limit = 5; FILE *file; file = fopen("C:\\Documents and Settings\\jon\\My Documents\\Visual Studio 2008\\Projects\\Project1\\Assignment8_2\\Debug\\TestFil...

Segmentation fault only when running on multi-core

I am using a c++ library that is meant to be multi-threaded and the number of working threads can be set using a variable. The library uses pthreads. The problem appears when I run the application ,that is provided as a test of library, on a quad-core machine using 3 threads or more. The application exits with a segmentation fault runtim...

swapping container with self referencing element

When a container contains elements which has a pointer to the container itself, the standard version of swap through pointer exchange doesn't work, and the swap doesn't check any such possibility. Is there any way to tell the container that standard swap doesn't work, and to use some different version? What is the best way to implement...

What can cause throughput to become really slow when an ISAPI filter implements SF_NOTIFY_SEND_RAW_DATA?

I have an ISAPI filter for IIS6 that I've been developing for a while, but I just noticed something disturbing. Anytime I have the filter installed and I download a file, the file download becomes really slow. From a remote machine I'm getting ~120kb per second without the filter installed, and ~45kb per second with the filter installed....

Need help on getArea() function

Hi, I'm trying to calculate the area of the circle and the rectangle by using the existing data (radius ,width, and height). But i have some errors, i hope you can help me fix it. #include <iostream> #include <vector> #include <string> using namespace std; class Shape { public: virtual void Draw () = 0; virtual void MoveTo (int ...

C++ version of Java PropertySheet

Previously, I am able to use PropertySheet provided by http://www.l2fprod.com/common/index.php When I pass in an Java Object, a GUI windows will be created automatically, to display the property of the object. User will able to view and edit the properties of the object. For C++, I know it is difficult to obtain object's properties dur...

Why is this the same even when object pointers differ in multiple inheritance?

When using multiple inheritance C++ has to maintain several vtables which leads to having "several views" of common base classes. Here's a code snippet: #include "stdafx.h" #include <Windows.h> void dumpPointer( void* pointer ) { __int64 thisPointer = reinterpret_cast<__int64>( pointer ); char buffer[100]; _i64toa( thisPoin...

C-style Variable initialization in PHP

Is there such a thing as local, private, static and public variables in PHP? If so, can you give samples of each and how their scope is demonstrated inside and outside the class and inside functions? ...

Interface hierarchy design pattern?

I'm in the early stages of developing a C++ multi platform (mobile) application which has a graphical user interface. I'm trying to find a good way of abstracting the actual UI/windowing implementation. Here is basically what I have tried so far: I created an interface hierarchy Screen +Canvas +Form +Dialog Control +EditBox +Che...