templates

template parameters, #define and code duplication

I have a lot of code like this: #define WITH_FEATURE_X struct A { #ifdef WITH_FEATURE_X // ... declare some variables Y #endif void f (); }; void A::f () { // ... do something #ifdef WITH_FEATURE_X // ... do something and use Y #else // ... do something else #endif // ... do something } and I'd like to replace the #defin...

Accessing public inherited Template data members

Hi, I require some clarification on the question why do we need the scope resolution operator or this pointer to access publicly inherited members from a template base class. As I understand it is for adding clarity but then how does this add any further clarity than just point that it is a member of the class. To make my question clear...

smarty template compile directory not writable

hello all, i'm using the latest version of smarty (3.0rc3). i made my templates_c directory writable in command line (chmod -R 777 templates_c) but smarty still outputs this when i call $smart->utility->testInstall(); Testing compile directory... FAILED: ./php/classes/smarty/templates_c/ is not writable. Warning: rename(/tmp/wrtub1GxS,...

Using text/html javascript templates in production code

Has anyone implemented John Resig's micro-templating in production code? In particular I'd like to know if embedding the templates with <script type="text/html"> has caused any problems. A bit more information: here's the sort of thing I'm worried about: My users are mostly in corporate environments - could an unusual proxy server man...

Check if a class has a method

Possible Duplicate: Possible for C++ template to check for a function's existence? Do you know of any metaprogramming tricks in C++ that allow me to check whether a class has a specific method. I has been thinking about something like this: template <class T, class Enable = void> class A { ... }; // This version of the clas...

T is not a class but it is.

Why this doesn't work? (For hell's sake!) template<class T> class A { typedef typename T::value_type value_type; public: A(); }; I'm getting following error: Error 1 error C2825: 'T': must be a class or namespace when followed by ':: But T is a class, I've just specified that didn't I? So what's the problem? Thanks. ...

enable_if on overloaded operator with different return type

I am trying to basically do 3 things at once here: overload the assignment operator using a template, restrict the types (using boost::enable_if), and having a specific return type. Take this as an example: template <class T> std::string operator =(T t) { return "some string"; } Now, according to boost enable_if (sec 3, bullet pt 1)...

c++ template syntax

How do I fix this syntax error? struct A { template < typename T > void f () {} }; template < typename C, typename U > struct B { void g () { U::f < C > (); // expected primary-expression before »>« token } }; int main () { B<int,A> b; b.g (); } ...

I can't modify the template i assigned to the Posts page (Wordpress)

I created 2 files: home.php and blog.php. The first one is set to be my Front Page and the later to be the Posts page. When I modify home.php I can see the changes (for instance deleting the sidebar). But when I try to modify blog.php nothing happens. Do I have to modify other .php file in order to see changes in the Blog (Posts page) p...

ajax editing in Telerik Grid, Display Templates are not rendered when update the row.

I have a telerik grid, when I edit a row: but if i pressed the update button or even cancel(watch the mid column): here is the declaration: <%= Html.Telerik().Grid<AlefTech.HumanResource.WebModule.ViewDto.MaritialStatusItemEditDto>(Model) .Name("Grid") .DataKeys(keys => { keys.Add(c => c.MaritialStatusItemID); ...

Count of parameters in a parameter pack? Is there a C++0x std lib function for this?

I was just wondering if there was anything in the C++0x std lib already available to count the number of parameters in a parameter pack? I'd like to get rid of the field_count in the code below. I know I can build my own counter, but it just seems like this would be an obvious thing to include in the C++0x std lib, and I wanted to be s...

custom field template... file upload problem

Hi Gyus, I am facing problems with custom field template. it is not uploading the custom image file to the latest path, and tries to fetch from the path it stores in db. which is wp-content/uploads/2010/06/ but it doesnt upload the file here. any help, thanks in advanced. Regards, Farrukh ...

JSF template not applied

Hey, I created template (template.xhtml) which resides in root context of application. I wanted to apply it to page (newTemplateClient.xhtml) which resides in the folder 'public'. So newTemplateClient.xhtml looks like this: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "ht...

Python Cheetah - Specify name/value pairs for templating

I am trying to template-ize my Apache httpd configuration for deployment to different environments and I would like to use the Python language Cheetah application to do so. However, I am having difficulty with the command line cheetah program and I believe its a combination of my misunderstanding Cheetah along with a lack of documentatio...

C++ templated function and forward declarations

I'm working on some code that compiles and links (and even has released commercial products) on Windows using MSVC. It doesn't compile with GCC though, I get the following errors: .../CBaseValue.h: In member function 'bool CBaseValue::InstanceOf()': .../CBaseValue.h:90:18: error: invalid use of incomplete type 'struct CValueType' .../CB...

What is the best template to use in C# Visual Studio 2008 for a 2D game?

Is it WPF? WFA? A custom template? I currently use WFA, and it just doesn't seem anywhere near optimal. And no, I'm not asking for a referral to DirectX, or another language. Thanks. ...

ADL and friend injection

Consider this code: template <int N> struct X { friend void f(X *) {} }; int main() { f((X<0> *)0); // Error? } compilers seem to heavily disagree. (MSVC08/10 says no, GCC<4.5 says yes, but 4.5 says no, sun 5.1 says yes, intel 11.1 says yes too but comeau says no (both are EDG)). According to "C++ Templates - The complete guide": ...

WPF ControlTemplates must have TargetType or not?

Do ControlTemplates in WPF require a TargetType? I am restyling some controls, and notice that the comboboxitem, listiviewitem and listboxitem all have the same template: <ControlTemplate x:Key="ListBoxItemCT" TargetType="{x:Type ListBoxItem}"> <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{Templa...

How can I strip whitespace and newlines with Mako templates? My 12362 line HTML file is killing IE

I'm using the Mako template system in my Pylons website and am having some issues with stripping whitespace. My reasoning for stripping whitespace is the generated HTML file comes out as 12363 lines of code. This, I assume, is why Internet Explorer is hanging when it tries to load it. I want to be able to have my HTML file look nice an...

Why are templates so slow to compile?

Large templated projects are slow to compile, the STL being a main culprit of this it seems from empiric evidence. But, why is it slow to compile? I've optimized builds before by watching for header includes and by combining compilation units, but I don't get why template libraries are quite so slow to compile. ...