templates

Why the template for a webform got a different behavior than the IDE?

If you open this zip file C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\VisualBasic\Web\1033\WebForm.zip in this file Default.aspx.vb you will see this code Public Partial Class $classname$ Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) H...

How could I improve this template system?

At the moment, I have a base HTML template file. When ever I want to make a new page, I copy the template and place some require_once statements in between specific tags. I was wondering if there's a better way that would make it unnecessary to copy the template each time. Here's a typical example: <html> <head> <meta http-equi...

g++ duplicate symbol error when working with templates (noob question)

Hi, So I'm trying to pick C++, and to do so I decided to write a generic Group class using templates, that takes a Type and size as template parameters: in group.h: #ifndef __GROUP_H #define __GROUP_H #define MAX_SIZE 10 /********************************************************** * Define a Group class that handles a collection of m...

"templating" a namespace

Hi, I'd like to build something like this: File 1: template<typename Vector> namespace myNamespace { class myClass1{ myClass1(Vector v) {...} } } File 2: template<typename Vector> namespace myNamespace { class myClass2{ myClass2(Vector v) {...} } } Of course this is not possible because you cannot template namespaces. Instead I ...

C++ template duck-typing vs pure virtual base class inheritance

Which are the guidelines for choosing between template duck-typing and pure virtual base class inheritance? Examples: // templates class duck { void sing() { std::cout << "quack\n"; } }; template<typename bird> void somefunc(const bird& b) { b.sing(); } // pure virtual base class class bird { virtual void sing() = 0; }; c...

Dynamic hash->class tag

I have: const unsigned int hash_1 = 0xaf019b0c; const unsigned int hash_2 = 0xf864e55c; const unsigned int hash_3 = 0xfaea8ed5; Hashes come from an automatically generated header. These hashes are indirectly associated with tags 1, 2, 3. The tags are associated with classes through a simple compile-time generated id. That way I can ...

Catching functors using SFINAE in structure partial specialisation

Hi, For some complicated reason, I want to convert any supported type T (coming from a template) to a list of types I have chosen. For this, I tried using a template structure named "Convert". For example: Convert<short>::type should be int Convert<int>::type should be int Convert<char>::type should be int Convert<float>::type should b...

Strange "Could not deduce template argument for 'T'" error

The error is in this code: //myutil.h template <class T, class predicate> T ConditionalInput(LPSTR inputMessage, LPSTR errorMessage, predicate condition); //myutil.cpp template <class T, class Pred> T ConditionalInput(LPSTR inputMessage, LPSTR errorMessage, Pred condition) { T input cout<< inputMessage; cin>...

Problem with C++ templates

Hi All I am trying to build small logger library. I am facig some problem with c++ templates. Here is what my class structure looks like. class abstract_logger_t { public: typedef abstract_logger_t logger_type; template<typename data_t> abstract_logger_t& log(const data_t& data) { return *this; } }; class stdout_logger_t ...

How to increase padding displayed items combobox?

I want to write XAML template of a combobox to increase the spaces/padding between items. I searched for this but almost end up with the ItemsPresenter: <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/...

Partially change a WPF template for a standard control

I have a TextBox control placed inside my window and I would like to change its Border. In order to do this, I have to somehow modify the existing Border set by the default control template. Is there a way to modify only a part of a default control template (for a standard WPF control) by somehow overriding the existing objects? ...

Container that doesn't require its elements to be default and copy constructible

I'm looking for a C++ container-like class that wraps a typed array of objects that are not necessarily initialized and don't have to be default-constructible or copy-constructible. This would be interesting for RAII objects that have no well-defined copy semantics. Such a container-like class seems to be fairly easy to write (using an a...

File Local Define

Hey all; This question more falls into the category of best practices, and clean/safe code for distribution. I'm working on a math library in c++, for my portfolio, and to use during my last two semesters of College. I want this library to be very easy to use, and to minimize the possibilities of conflicts with pre existing code. For...

use common template for all pages of website

ok, the title did not make much sense but this is what i am planning to do. I have designed a template for my website, with head body and div for specific stuff and everything. The website consists of header file, footer file, right-side column, header dropdown menu and a main body which would be present beneath the header dropdown menu...

C++: using const with STL iterators

From Effective C++, Item 3 /* case1 */ const std::vector<int>::iterator i // i acts like a T* const /* case2 */ std::vector<int>::const_iterator ci // ci acts like a const T* To remember how const applies, I used to remember the following from this article Basically ‘const’ applies to whatever is on its immediate left (other t...

Processing a binary file - templated functions problem

I've created a small tool which is used to process binary files. All the functions involved in reading the files and processing them are templated and are similar to this: template <class T> void processFile( const char* fileName ); The template parameter T is used to determine the size of data which will be read and treated as one it...

Outputting Literal curly braces in Liquid templates

I'm trying to output the following from within a liquid template: {{ example }} Obviously, Liquid sees this as a variable named example and tries to do substitution. I'm trying to find out how I can output the actual braces. So far, I've found one method that works, but it's incredibly ugly: {{ '{example'|prepend:'{' }}}} Yeah, to...

Overloading + Operator With Templates.

Hey, I'm getting a linker error LNK2019: unresolved external symbol when trying to use an overloaded + operator. I'll show you snip-its from the class, and how I'm using it in main. If you need to see more, let me know, I'm just going to try and keep things concise. /** vec.h **/ #ifndef __VEC_H_ #define __VEC_H_ #include <iostream> #...

What's the best way to get a description of the website, in Python?

Suppose I downloaded the HTML code, and I can parse it. How do I get the "best" description of that website, if that website does not have meta-description tag? ...

CPP templated member function specialization

Hi, I'm trying to specialize the member function moment() only (not the hole class) like this: template<class Derived, class T> class AbstractWavelet { public: [...] template<bool useCache> const typename T::scalar moment(const int i, const int j) const { return abstractWaveletSpecialization<Derived, T, useCache>::moment(sta...