templates

std::pair expecting a 'type', but I am giving it a type

This is my code: typedef std::hash_multimap<Vertice<VerticeType, WeightType>*, Edge<VerticeType, WeightType>*> ght; std::pair<ght::iterator, ght::iterator> getEdgesFromVertice(Vertice<VerticeType, WeightType>*); When I try to compile it, it gives me an error saying: error: type/value mismatch at argument 1 in template parameter list ...

How to delete a template?

i'm having truble with deleting my template my template and distructor : template<class S, class T> class Consortium { private : map<const S, Node<T>*> m_consortiumMap; Heap<T>m_consortiumHeap; public : ~Consortium(); void Insert(const S key, T toAdd); void Update(const S key); void Remove(const S key); ...

C++ Template Basics - Function Accept Sub Class or Super

Say you have a sub class B which inherits from super class A. You want a function that can accept either A or B. template <typename T> void someFunc(T* pObj, bool someOtherArg) { pObj->AnInheritMethod(); if (pObj->IsASub()) { pObj->ANonInhertMethod(); } } When I compile this (Visual Studio 6) I get: error C206...

(Relatively) Size-Safe Wrapped STL Container in C++

Bear with me because I'm self taught in C++ and am spending my limited extra time on the job to try to learn more about it (I'm a chemical engineering researcher by day). I have a pretty simple objective: 1. Make a size-safe container to store a long list of floats. 2. Make a specialized version of that container that acts as a matri...

unable to determine cause of "no match for 'operator<'" compilation error

I am using CodeSourcery's implementation of the vector signal image processing library (vsipl++). I have written a function that is supposed to return [I + a*A]^-1 B, where I is the identity matrix, and A and B are compatible square matrices, as follows: namespace vsipl { template< class T1, class T2, class O1, class O2, class L1, cla...

Private template classes/structs visibility

I don't understand why in the following code, I am allowed to create the function print_private_template while the compiler complains about print_private_class: #include <cstdio> class A { private: template <unsigned T> struct B { }; struct C { }; public: templ...

How can you dynamically alter blogger content with jquery?

$('.body-fauxcolumns').load('http://zazzlewidgets.blogspot.com/p/about-me.html'); I was experimenting with jquery and blogger and noticed that I can't change the content dynamically through manipulation functions. Am I doing something wrong? The code was placed into the header. How can you dynamically alter blogger content with jqu...

How to get Kohana base_url in template

In Kohana 3 bootstrap.php one can define base_url: Kohana::init(array( 'base_url' => '/foo/', )); This usually means also moving the /js/, /css/ and other media to that base dir like /foo/js/, /foo/css/. My question is not to discuss good or bad of such. Is there a built-in way in Kohana to access the base_url from a template (...

Confusing Template error

I've been playing with clang a while, and I stumbled upon "test/SemaTemplate/dependent-template-recover.cpp" (in the clang distribution) which is supposed to provide hints to recover from a template error. The whole thing can be easily stripped down to a minimal example: template<typename T, typename U, int N> struct X { void f(T* ...

Templates Non Type Parameters+ Lvalue/Rvalue

C++03 $14.1/6 - "A non-type non-reference template-parameter is not an lvalue." C++0x $14.2/6- "A non-type non-reference template-parameter is an rvalue." Is there any specific rationale behind rewording it? ...

Template type deduction of reference

I've been playing around with type deduction/printing using templates with code of the form: #include <iostream> template <typename T> class printType {}; template <typename T> std::ostream& operator<<(std::ostream& os, const printType<T>&) { os << "SomeType"; return os; } template <typename T> std::ostream& operator<<(std::ostr...

C++ templates and inheritance

Hi, can I mix inheritance and templates this way ? : template <class T> class AbstractType { // abstract //.... } template <class T> class Type1 : public AbstractType<T> { //.... } And later on, can I use these classes like this: AbstractType<SomeClass>* var1 = new Type1<SomeClass>(); Thx for help. ...

Outputting escaped characters in django templates

I want to use the django templating system to output csv like data which looks like; !connection%block !dosomething !dosomethingelse My,Header,Row,Which,Is,Comma,Seperated All,My,Comma,Seperated,Data All,My,Comma,Seperated,Data All,My,Comma,Seperated,Data All,My,Comma,Seperated,Data !Footerblock !that has footer information The actual...

Django: Login form in template tag

I've made a template tag to display a login form on various pages of my site. The idea behind that is also, that after logging in you see the same page/content as before and you don't get redirected to another page. I could do form validation & logging-in without any problems in the template-tag's render method, but the problem is, that...

Problems with TPLs after migrating PHP / Mysql Website

Hello, sorry if this question is vague, but I dont know ehere the problem is. I just had to migrate to a new server a big, crappy website from a client, that was developed by a different company and I have almost no documentation. The website is based on PHP, Mysql, and a TPL engine (the one from phpbb). I made sure to install the same...

Do you have a good Perl template script?

I do a lot of programming in Perl and was wondering if people had a "default" template Perl script that they use and willing to share. I started copying one of my older scripts which has Getopt functions. I am thinking people would have done something similar? ...

Passing a structure as a template-parameter - How can I fix this code?

Hi, I'm trying to compile the following code under VC2010. struct CircValRange { double a,b; // range: [a,b) }; template <struct CircValRange* Range> class CircVal { // todo }; const CircValRange SignedDegRange= {-180., 180.}; CircVal<SignedDegRange> x; I'm getting error C2970: 'CircVal' : template parameter 'Range' : 'S...

Relational container in c++ and polymorphism issues

Hi everyone. I would appreciate any help with this. I have a simple container template class Dataset. Also there is a specialization to allow a different implementation when a Dataset of Datasets is instantiated. Since a Dataset of Datasets would be a heterogeneous container, there is a base abstract class List wich must declare a com...

Looking for a popular templating language that needs XSS protection

I'd like to experiment with a popular HTML templating language to see if I can solve XSS problems in it. What is a popular, open-source, templating language that I could try to tackle. By templating language, I mean a language used to generate an output language by combining static content in that output language with dynamic data from...

Template doubt in C++

#include <iostream> using namespace std; template<typename T> void test() { cout << "Called from template T"; } template<int I> void test() { cout << "Called from int"; } int main() { test<int()>(); } In the above snippet test<int()>() calls the first version and gives output Called fro...