templates

C++ non-member functions for nested template classes

I have been writing several class templates that contain nested iterator classes, for which an equality comparison is required. As I believe is fairly typical, the comparison is performed with a non-member (and non-friend) operator== function. In doing so, my compiler (I'm using Mingw32 GCC 4.4 with flags -O3 -g -Wall) fails to find the ...

Get the current URL within a django template

Hay, i was wondering how to get the current URL within a template. Say my URL was /user/profile/ How do i return this to the template? Thanks ...

WPF Custom Control - Designer looks fine, but I get a runtime issue...

MainWindow.xaml <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:MyStuff;assembly=MyStuff" Title="MainWindow" Height="350" Width="525"> <Grid> <TabControl Margin="5"> ...

Template compiling errors on iPhone SDK 3.2

I'm porting over some templated code from Windows and I'm hitting some compiler differences on the iPhone 3.2 SDK. Original code inside a class template's member function is: return BinarySearch<uint32, CSimpleKey<T> >(key); where BinarySearch is a method inherited from another template. This produces the following error: csimpleke...

Functionality Workthrough of "price.phtml" template of catalog products in Magento

Can anybody please describe the total walkthrough of the catalog product's price.phtml template file? I have been trying to understand its full functionality, in how it implements its price logic, for the special price, wee price, regular price, and all of those; but have reached nowhere till now. Any help is greatly appreciated. After...

How to templatize the container type in a function declaration?

I want to write a function that accepts any container holding strings. Something like this: template <typename Container> void foo(Container<string>& stuff); But this isn't the right syntax. What's the right syntax? ...

Multi-argument template functions, overloading and ambiguity errors.

Lets say I'm writing a some kind of conversion operator, and I want to use it like that: SomeType a; AnotherType b = conv<AnotherType>(a); First, I write the base (default) function: template <typename T, typename U> inline T conv(const U& a) { return T(a); } Full specialization (or a non-template overload) is not a problem, ho...

Getting a type for a template instantiation?

I have the following situation: I have a object of type MyClass, which has a method to cast itself to its base class. The class includes a typedef for its base class and a method to do the upcast. template <class T, class B> class BaseClass; template <class T> class NoAccess; template <class T> class MyClass : public BaseClass<T, NoA...

C++ template name pretty print

hello. I have need to print indented template names for debugging purposes. For example, instead of single-line, I would like to indent name like this: boost::phoenix::actor< boost::phoenix::composite< boost::phoenix::less_eval, boost::fusion::vector< boost::phoenix::argument<0>, boost::phoenix::argument<...

Extracting bool from istream in a templated function

I'm converting my fields class read functions into one template function. I have field classes for int, unsigned int, long, and unsigned long. These all use the same method for extracting a value from an istringstream (only the types change): template <typename Value_Type> Value_Type Extract_Value(const std::string& input_string) { ...

Visitor and templated virtual methods

In a typical implementation of the Visitor pattern, the class must account for all variations (descendants) of the base class. There are many instances where the same method content in the visitor is applied to the different methods. A templated virtual method would be ideal in this case, but for now, this is not allowed. So, can te...

inspect C++ template instantiation

hello. Is there some utility which would allow me to inspect template instantiation? my compiler is g++ or Intel. Specific points I would like: Step by step instantiation. Instantiation backtrace (can hack this by crashing compiler. Better method?) Inspection of template parameters. @gf helpd me with simple type printing, http://s...

Where can I find the project templates for ASP.NET MVC 1.0?

I would like to edit the ASP.NET MVC templates for Visual Studio so that any new action or controller created has a specific piece of code within it by default. For instance, I'd like to replace the generated: public ActionResult MyAction() { return View(); } with a specific coding standard we prefer to use within...

C++ creating generic template function specialisations

I know how to specialise a template function, however what I want to do here is specialise a function for all types which have a given method, eg: template<typename T> void foo(){...} template<typename T, if_exists(T::bar)>void foo(){...}//always use this one if the method T::bar exists T::bar in my classes is static and has differen...

Declare variables that depend on unknown type in template functions.

Suppose I'm writing a template function foo that has type parameter T. It gets an object of type T that must have method bar(). And inside foo I want to create a vector of objects of type returned by bar. In GNU C++ I can write something like that: template<typename T> void foo(T x) { std::vector<__typeof(x.bar())> v; v.push_b...

can these templates be made unambiguous

I'm trying to create a set of overloaded templates for arrays/pointers where one template will be used when the compiler knows the size of the array and the other template will be used when it doesn't: template <typename T, size_t SZ> void moo(T (&arr)[SZ]) { ... } template <typename T> void moo(T *ptr) { ... } The problem is that wh...

If the address of a function can not be resolved during deduction, is it SFINAE or a compiler error?

In C++0x SFINAE rules have been simplified such that any invalid expression or type that occurs in the "immediate context" of deduction does not result in a compiler error but rather in deduction failure (SFINAE). My question is this: If I take the address of an overloaded function and it can not be resolved, is that failure in the im...

C++: Can virtual inheritance be detected at compile time?

I would like to determine at compile time if a pointer to Derived can be cast from a pointer to Base without dynamic_cast<>. Is this possible using templates and metaprogramming? This isn't exactly the same problem as determining if Base is a virtual base class of Derived, because Base could be the super class of a virtual base class of ...

Can I create template-based library objects in Dreamweaver CS5?

At work we need two 'streams' of template. The first are general layout templates, like the ones already available in the MX through CS5 packages (except we'd have our own customised ones). The second are more granular objects, some of which are functional. In both cases, I don't want Jimmy to be able to wreak havoc inside anything othe...

Html.hiddenfor does not return value

Hi I have a template partial view, which used to render a model named VerificationCode, this model has a element 'CaptchaGeneratedText' which is hidden in the view and set value by Html.HiddenFor(m=>m.CaptchaGeneratedText, captchaText), the problem is when view post, in the model validation the value of element 'CaptchaGeneratedText...