templates

How to solve a template issue to save different data types to file?

I came a across a new problem when using templates. This is me being a little creative from a book I recently read, expanding his ideas, and it has this code example. Say you have a templated Array2D class. And you have this method (Array2D::WriteFile): bool WriteFile( const char* p_filename ) { FILE* outfile = 0; int writt...

Tool to easily create a wxPython preference dialog from a template ?

I need a wxPython preference dialog box from a Python application. I could hand-code it (and use wxGlade to do part of the job), but I was wondering if there is no tool that makes creation of simple preference dialog boxes easier. The 'easier' part would be in that you can specify that you need e.g. a text box, and both the GUI elements...

Add a new language to gtksourceview (Django's template language for gedit)

Edit: I found the problem : in another context, there was a % in a regexp, so the %} was not interpreted. Hello ! I got a problem to add a new language to gtksourceview (used by gedit). I want to add the Django's template language and something does not work : I am not able to make %} stop the syntactic coloring. Here is a snippet : ...

Is it possible to transform the types in a parameter pack?

Is it possible to transform the types of a parameter pack and pass it on? E.g. given the following: template<class... Args> struct X {}; template<class T> struct make_pointer { typedef T* type; }; template<class T> struct make_pointer<T*> { typedef T* type; }; Can we define a template magic or something similar so that the follow...

operator<<() for template class

I want to overload operator <<() for my own class that is also a template. My classes are as follows: template< typename RefCountType, typename TraitsType = std::char_traits<char>, typename Allocator = std::allocator<typename TraitsType::char_type> > class rep { // ... }; template<typename RepType> class t_zstring { ...

Using member of template class to instantiate template default parameter in MSVC++

The following piece of code is a reduced sample from the large project I'm trying to port from GCC/G++ to Microsoft Visual C++ 2010. It compiles fine with G++, but with MSVC++, it throws errors, and I'm having trouble understanding why. template <typename A, typename B = typename A::C::D> // line 1 struct foo { typedef int type; }...

Dependent Non-Type Template Parameters

Consider the following class: class Foo { enum Flags {Bar, Baz, Bax}; template<Flags, class = void> struct Internal; template<class unused> struct Internal<Bar, unused> {/* ... */}; template<class unused> struct Internal<Baz, unused> {/* ... */}; template<class unused> struct Internal<Bax, unused> {/* ... */}; }; The class...

Rails - Missing template users/#<User:0x8334c18>.erb in view path app/views

I'm not sure what I could be doing to get this error. Obviously, I don't think I should be creating the specific file it mentions in my app\views folder. Can anybody point me in the right direction? ...

a new approach to web development: request for tools and components recommendations

I'm searching for the best possibility to write web applications that are heavy with JavaScript . So I'd like to present you my ideas and ask for your opinions and alternatives on this, please :) 1 year ago I started looking for possibilities for web development besides PHP. I found JSP and Django. I decided to go with Django. After sta...

C++ Template class inheriting another template class with a template-specified input type

Possible Duplicates: GCC problem : using a member of a base class that depends on a template argument Why does GCC need extra declarations in templates when VS does not? Why doesnt a derived template class have access to a base template class iphone compiler inherited templated base classes with passed through type not being e...

Templates, STL, C++

I wrote this routine to order items, keep only unique items, where it takes in an array of type T, and the size of the array. It returns the new size of the array after processing. template <class T> int reduce(T array[], int size) { T *begin = array; T *end = array + size; sort(begin, end); T *end_new = unique(begin,...

Template syntax help

Two questions for an assignment, first is the first set of errors for my template in a the CharComparator.h file, I don't see why it is complaining. The second question is why that I added include "CharComparator.h" to my main.cpp file, I get a bunch more of compiler errors. Here are my files: CharComparator.h #ifndef CHARCOMPARATOR_...

What does void(U::*)(void) mean?

I was looking at the implementation of the is_class template in Boost, and ran into some syntax I can't easily decipher. template <class U> static ::boost::type_traits::yes_type is_class_tester(void(U::*)(void)); template <class U> static ::boost::type_traits::no_type is_class_tester(...); How do I interpret void(U::*)(void) a...

Easy way to get Drupal Header and Footer?

The title is probably not the best description. I want two functions: getHeader(); getFooter(); The header must return all the content in the template.php file BEFORE print $content; And the latter must return everything after it. Is this possible? ...

Passing objects of different types with the same interface

I have a number of class, all with exactly the same interface. This interface defines a few methods, some of which are templated (the class itself may or may not be). So the interface looks something like this class MyClass { public: void Func1(); template <typename T> void Func2(T param); }; I have a number of functions whic...

can I specialize operator<< ?

Hi, I want to specialize operator<< but this code is not compiling; template<> std::ostream& operator<< < my_type >( std::ostream& strm, my_type obj); ...

Differences between a `typename` parameterized template and and integral type one.

I've been trying to work with templates for a while now and the more I do the less I realise I understand. This latest problem feels like it has unearthed a rather fundamental misunderstanding on my part and I'm starting to think more than ever that, "Right, tomorrow I shouldn't write any code but instead find a library with a good CS se...

Eclipse CDT "New Class" Template

Hi, I have been using Eclipse CDT for some time now, and I love it, but there are a few tedious things that I would like to fix up about it. When you create a new file, one of the options is "New"->"Class". I was wondering if anyone knows of a way to edit the "${declarations}" section of this "Class" template. To be more specific, I h...

Help understanding class example code for C++, templates, operator()

I'm not sure exactly what the following class does that we have for a class example. In the following code, what does the operator() do in this case? I don't quite get the *(begin + first) and pretty much the whole return expression as what is being evaluated. Any help would be great. Thanks! // IndexCompare.h - interface for IndexC...

Problems understanding iterators and operator overload in c++

We have a class example and I just don't get it. I don't quite understand how the operator() works in this case, and everything starting with sort. I looked at the output after running the program, and I don't see how those values are obtained. sort indices array: 2 8 10 4 1 7 5 3 0 9 6 11 replay numbers array: 37 33 29 36 32 35 39 ...