templates

VisualStudio C++ Linker problem with template classes

I still can't get it to work.. After I had to separate implementation from definition of one of my generic classes because of a forward declaration, i now get Linker errors when trying to build. IShader.h: template <typename ShadeType> class IShader { public: template <typename T> bool getProperty(const std::string& propertyName, Sh...

How to save pointer to member in compile time?

Consider the following code template<typename T, int N> struct A { typedef T value_type; // OK. save T to value_type static const int size = N; // OK. save N to size }; Look, it is possible to save any template parameter if this parameter is a typename or an integer value. The thing is that pointer to member is an offset, i.e. int...

Is there pointer to member traits or something like this?

Based on other my question. Consider the following code template<typename T, int N> struct A { typedef T value_type; // save T to value_type static const int size = N; // save N to size }; Look, I can use value_type and size as template parameter. typedef A<int, 2> A1; typedef A<A1::value_type, A1::size + 3> A2; // OK, A2 is A...

boost::bind & boost::function pointers to overloaded or templated member functions

I have a callback mechanism, the classes involved are: class App { void onEvent(const MyEvent& event); void onEvent(const MyOtherEvent& event); Connector connect; } class Connector { template <class T> void Subscribe(boost::function <void (const T&)> callback); } App::App() { connect.Subscribe<MyEvent>(&App::OnEv...

Handling of references in C++ templates

I currently have a function template, taking a reference, that does something in essence equivalent to: template <typename T> void f(T& t) { t = T(); } Now, I can call: int a; f(a); To initialize my variable a. I can even do: std::vector<int> a(10); f(a[5]); However, this will fail: std::vector<bool> a(10); f(a[5]); The re...

How to put text into circle in WPF XAML template?

Thanks for any help. ...

Template type deduction in C++ for Class vs Function?

Why is that automatic type deduction is possible only for functions and not for Classes? ...

Using typedef from inside a template as template argument type

I'm trying to do something like this (completely synthetic example, because the real code is a bit to convoluted): enum MyInfoType { Value1, Value2 }; template<typename T> struct My_Type_Traits {}; template<> struct My_Type_Traits<int> { typedef MyInfoType InfoType; }; template<typename T> class Wrap { template<My_Type_T...

Accessing Template item in code behind a Silverlight control

I've created a custom control for use in my Silverlight application. Its template is defined in the control library's Generic.xaml. Is there any way to set properties of the items in that template from the control's .cs file? ...

Solaris C++ stream input >> operator and templates of templates

I there a compiler option I could use in CC compiler to get the following code (which compiles fine in Visual C++) std::vector<std::vector<double>> v2; without the following error Error: "," expected instead of ">>" ...

Function template specialization in derived class.

Hello all, I've a base class with a function template. I derive from base class and try to have a specialization for the function template in derived class I did something like this. class Base { .. template <typename T> fun (T arg) { ... } }; class Derived : public Base { ... } ; template <> Derived::fun(int arg); and in .cpp ...

Simple news archive with Smarty?

There is a simple table of news articles: [ id | title | body | created ]. What is the best way to create a simple news archive using smarty from a full collection of articles ordered by created date? In the format: 2009 12.11. Title 03.03. Title 01.01. Title 2008 11.12. Title 04.03. Title 02.03. Title 16.02. Title 2007 ... ... ...

Make WordPress sticky posts behave as normal using caller_get_posts=1 isn't working

I'm making a specific single.php template. It's using a jQuery slider to slide from one post to the next. In order to show the right post first, I have to use 2 loops - one to call the first single post, and then another loop to call all the other posts in the category. This I do like this (might be a bit mucky, I'm no PHP guru) <ul id...

Changable return data type in C++

I'm writing a matrix class, and I want it to be able to store any different (numerical) data type - from boolean to long. In order to access the data I'm using the brackets operator. Is it possible to make that function return different data types depending on which data type is stored within the class. What's MORE is that I'm not entir...

Multiple files in Dev-C++, Linker Error. Templates.

I apologise for what I'm pretty sure is a fairly stupid question, but I can't get it to work! I'm also not sure what information is too much information so I probably won't give enough info so sorry for that too - just ask. I began writing a class within main.cpp, and it got large so I decided to shift it to a different source file. I'...

Using type of function pointer as template argument

I'm trying to write a template which gets the type of a functionpointer as templateargument and the corresponding functionpointer as a function argument, so as a simplyfied example I'm doing this right now: int myfunc(int a) { return a; } template<typename T, typename Func> struct Test { typedef typeof(myfunc) Fun; static T MyF...

Set default program to open special file extension in vs.net

Hi, I want to set special program to open my template item in visual studio and deploying this to other VS.net. when you add new crystal report in your project it open with crystal report editor by default (right-click on rpt file and select open with option) I want to set my program to open file with special extension in vs.net (my exte...

Storing a Type as a Variable? for a templated class?

Hi, i have a templated class, with the following definition: ImageRescaleDepth<PIXEL_TYPE_INPUT, PIXEL_TYPE_OUTPUT> This class uses templates, for pretty much everything since its supposed to be generic. Anyways i need to make a command line version of this application, to do image rescaling, currently the system is setup to handle th...

C++ templating question regarding comparators

Probably a very newb C++ question. Say I have a class, vertex, with several properties and methods. I want to stuff a bunch of vertices into a queue, and have them ordered by a special property on the vertex class (doing a basic Dijkstra graph algo for school yes). I'm having some problems penetrating the C++ syntax however. Here is my ...

zend_pdf can't read existing pdf

Hi, I'm using Zend_Pdf to generate PDF files, based on existing PDF templates. The problem is, I can't read any of the templates - I get a "File is not a PDF." error because the first 4 characters in the file are "%???" instead of "%PDF" (I used "head" to check this). Is this a character encoding problem? I believe the templates are in...