templates

Using boost::optional with constant types - C++

I have a container class which uses boost::optional to hold the value. Here is the code looks like, template<typename T> struct traits { typedef T value_type; typedef T& reference; }; template<typename T> struct traits<const T> { typedef const T value_type; typedef const T& reference; }; template<typename T> struct t...

Creating T4 templates at runtime (build-time)?

We are building an inhouse application which needs to generate HTML files for upload into eBay listings. We are looking to use a template engine to generate the HTML files based on database and static fields that we have pre-defined. The template also needs to have logic capabilities (if-then, foreach, etc). We have looked at T4 and it ...

How can I make pages with custom Html easily in Joomla?

Our customer wants to use Joomla! and I have no prior experience of it. I have been looking thru Joomla! documentation and tutorials over net, but I just cannot find how can I make just static html pages and menu. Joomla! adds some tables (for layout!) in your articles and it of course will ruin my own html. ...

deriving a templated class in c++

I have a templated base class which follows: template<class scalar_type, template<typename > class functor> class convex_opt{ .. }; How to derive a class from this templated class? ...

template specialization for CPPUnit isn't being used

If you've used CPPUnit before, you are probably aware of its assertion_traits class that is templatized to handle arbitrary types. This is what allows it to print the "actual" and "expected" values for non-string types when test cases fail. I have used this with success several times, but for one specific type it isn't working for me. ...

C++ template class T trouble

template <class T> class List { public: List(); ~List(); ... protected: template <class T> struct Item { struct Item* next; T data; }; ... struct Item<T>* allocate(); }; template <class T> struct Item<T>* List<T>::allocate() // error he...

C++ in template initialization

Given the following piece of code: template<typename T> class MyContainer { typedef T value_type; typedef unsigned int size_type; ... }; How one should initialize variables using size_type (like loop indexes)? Should it be: for(size_type currentIndex = size_type(0);currentIndex < bound;++currentIndex) or for(size_type...

Facebook Connect button question - please help.

<fb:login-button onlogin="window.location = '/custompage.html';">Connect</fb:login-button> That's currently my code for users to log in to my site. It's in FBML. It will pop up a box, the user then logs in. And then, it closes the new window, followed by a redirect to "custompage.html". Now, I would like to manually render my button ...

How to print line breaks in Python Django template.

{'quotes': u'Live before you die.\n\n"Dream as if you\'ll live forever, live as if you\'ll die today"\n\n"Love one person, take care of them until you die. You know, raise kids. Have a good life. Be a good friend. Try to be completely who you are, figure out what you personally love and go after it with everything you\'ve got no matter h...

T4 template mandatory config values

i am planning to use T4 template to generate the config files. i have a main.tt file with basic settings. there are different .tt file for each environment which include the main.tt one thing which i want to achieve is how do i make sure that each environment specific .tt files override the main.tt variables. i need to do this since i wa...

Where can I find a SWIFT form in HTML?

I'm developing a banking/accounting system and want to make possible printing a SWIFT (Society for Worldwide Interbank Financial Telecommunication) payment order. Does anybody meet a HTML template of such form? ...

What is the preference of function/method/template name resolving in C++?

How does the C++ compiler decide which function/method to call if there are multiple possibilities? In my specific case I have the standard free function of the C++ Run time and I also have a templated free variant, like this: // The definitions of the C++ Run Time Library (from memory.h) extern malloc(size_t s); extern void free(void *...

How do you create a simple comment header template for all new classes in Visual C++ 2010?

This may be a duplicate, but I haven't found anything that answers it thus far. My company passed a resolution that all files need to have a boilerplate comment header, with file name and copyright date among other things. I was hoping there would be an easy way to just create a header template that is added to the top of every new cla...

Eliminate repetition in C++ code?

Given the following: StreamLogger& operator<<(const char* s) { elements.push_back(String(s)); return *this; } StreamLogger& operator<<(int val) { elements.push_back(String(asString<int>(val))); return *this; } StreamLogger& operator<<(unsigned val) { elements.push_back(String(asString<unsigned>(val))); return *this; } Str...

Templating off of an arbitirary-length list of types in C++

Here's what I want to be able to type: class foo : public watchKeys<A, B, C> {}; //Or any list of keys Boost::mpl has sequences, which allow you to do this, but I don't want to have to do: class foo : public watchKeys<mpl::list<A, B, C> > {}; I don't mind it being "ugly" or verbose on the inside, but I want the way watchKeys is ult...

How to force template function overload for boost::bind?

Hi, I'm trying to create predicate for std::find_if by using boost::bind together with boost::contains (from boost/algoritm/string library). Following snippet shows two ways how I'm trying to accomplish this. #include <boost/algorithm/string.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> #include <iostream> #include <s...

python: string templates: what are legal characters?

I can't quite figure out what's going on with string templates: t = Template('cannot teach an ${dog.old} ${tricks.new}. ${why} is this ${not} working') print t.safe_substitute({'dog.old': 'old dog', 'tricks.new': 'new tricks', 'why': 'OH WHY', 'not': '@#%@#% NOT'}) This prints: cannot teach an ${dog.old} ${tricks.new}. OH WHY is this...

default template arguments in c++

Suppose i have a function template StrCompare template<typename T=NonCaseSenCompare>//NonCaseSenCompare is a user defined class look at the detailed code below. int StrCompare(char* str1, char* str2) { ... } now in the main function i write a line char* str1="Zia"; char* str2="zia"; int result=StrCompare(str1,str2); it should work...

Customize Sharepoint Alerts

Is it possible to customize the e-mail templates of Sharepoint server, in which, i don't have access for files and Central Administration. I'm using Sharepoint Designer to connect and edit my site currently. Thanks. ...

Can I populate list items in a ASP.NET dropdown list from a ASP.NET Placeholder?

I'm designing my own custom control that contains a .NET dropdownlist. What I'm wondering is if it is possible to populate my dropdownlist with listitems placed in a placeholder? For example: <asp:DropDownList ID="ddlFilter" runat="server" > <asp:PlaceHolder ID="ListItemPlaceholder" runat="server"/> </asp:DropDownList> This doesn't...