I would like to able to loop through past events in a template:
{% for page in m.search[{past cat='event'}] %}
{% if forloop.first %}<ul>{% endif %}
<h2>{{ m.rsc[page].date_start|date:"M j, Y" }} {{ m.rsc[page].title }}</h2>
<p>{{ m.rsc[page].body|show_media }}</p>
<p><a href="{{ m.rsc[page].website }}">Regis...
hello!
i'm used to write templates like this:
template<typename T>
void someFunction(SomeClass<T> argument);
however - now I encountered templates in another thread written like this:
template<U>
void someFunction(SomeClass<U> argument);
as far as i know one can use "typename" and "class" interchangably (except for some details re...
Hi all, I'm trying to make a pretty-printer for std::vector's of whatever ... doubles, my own custom classes... anything that has a friend std::ostream& operator<<.
However, when trying to compile the following function:
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> const& list) {
std::vector<T>::co...
Hi,
I'm wondering what's the proper syntax for calling template method given as:
struct print_ch {
print_ch(char const& ch) : m_ch(ch) { }
~print_ch() { }
template<typename T>
void operator()() {
std::cout << static_cast<T>(m_ch) << std::endl;
}
private:
char m_ch;
};
I came up with sth like this:
...
OK, suppose I want to check whether the template parameter has a nested type/typedef XYZ.
template <class T>
struct hasXZY
{
typedef char no;
typedef struct { char x[2]; } yes;
template <class U>
static yes f(typename U::XYZ*);
template <class /*U*/>
static no f(...);
enum {value = sizeof(f<T>(0))=...
In the trivial example inheritance hierarchy:
class Food
{
virtual ~Food();
};
class Fruit : public Food
{
virtual ~Fruit();
};
class Apple: public Fruit
{
virtual ~Apple();
}
class Vegetable: public Food
{
virtual ~Vegetable();
}
I wish to create a method that can clone an object from its subclass or baseclass inst...
Hello! Does someone know a way to achieve or emulate the following behaviour?
(this code results in compilation-time error).
E.g, I want to add specific template specialization only in derived classes.
struct Base {
template <typename T> void Method(T a) {
T b;
}
template <> void Method<int>(int a) {
float c;
}...
consider the following templated datastructures
enum eContent{
EINT = 1,
EFLOAT = 2,
EBOOL = 4
};
template<int>
struct Container{
Container(){assert(false);} //woops, don't do that!
};
template<>
struct Container<EINT>{
Container():i(123){}
int i;
};
template<>
struct Container<EFLOAT>{
Container():f(123.4...
This is kind of a follow-up from my other question.
When I first heard about generics, it was before the release of Delphi 2009 (Where they introduced it first). I know it was supported in .Net before that, but I have yet to dig in that realm.
Reading about generics, I learned that it allowed class to have a variable argument to it, an...
Can I call a non-member static templated function from a static member function where the definition is split into header and cpp:
// zero.cpp
class Zero
{
static void zero() { one(5); }
};
// one.h
template <typename T>
static void one(T& var);
// one.cpp
template <typename T>
void one(T& var) { }
// main.cpp
...
Zero::zero...
Hi assume that I have class A :
using namespace std;
template <class T>
class A{
private:
vector<T> my_V;
public:
// assume initializations etc are done
inline vector<T> get_v()
{
return my_v;
}
};
and some where else I have overloaded ostream of std::vector
template <class T>
ostream & operator<<(ostream& out, vector<T> &vec...
I'm trying to get the maximum size of any possible instance of my template as a compile time constant. The first thing that came to mind was something like this...
union TestUnion
{
template<typename T> class MyClass
{
public:
MyClass() { };
MyClass(T& t) : _t(t) { }
private:
T _t;
};
};
But sizeof(TestUnion) is always equ...
I'm trying to apply the technique described in http://www.drdobbs.com/tools/227500449
With the sample code below, I expect the output:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
And this is indeed what happens if I compile using clang. But with gcc, this code gives the following errors:
junk.cpp: In instantiation of ‘const bool has_fo...
Hey!
The following code:
jQuery(document).ready(function($) {
function getBooks() {
var query = "ajax.php?do=allbooks";
$.ajax({
dataType: "jsonp",
url: query,
jsonp: "callback",
success: showBooks
});
}
function showBooks(data)...
LANGUAGE_CODE = 'ru-RU'
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = False
{{ post.date_added|date:"b" }} gives "окт" in templates.
If I set USE_I18N = False then it gives oct as it should be.
Is this a bug ? How can I solve this problem ?...
I'm writing an MVC2 app using DataAnnotations. I have a following Model:
public class FooModel
{
[ScaffoldColumn("false")]
public long FooId { get; set; }
[UIHint("BarTemplate")]
public DateTime? Bar { get; set;}
}
I want to create a custom display template for Bar. I have created following template:
<%@ Control Lan...
Having my first attempt with PHP templates and i'm a bit confused separating business with presentation logic. I've choosen Dwoo as my template engine as you will see on the example below but my question is independent of Dwoo.
I see that what im doing isn't a good logic, it'll confuse the designer and it doesn't really separates PHP/HT...
Why can't a C++ compiler recognize that g() and b are inherited members of Superclass as seen in this code:
template<typename T> struct Superclass {
protected:
int b;
void g() {}
};
template<typename T> struct Subclass : public Superclass<T> {
void f() {
g(); // compiler error: uncategorized
b = 3; // compiler error: unr...
I have content that is going to be the exact same between the mobile and web site. The only thing i want to change is the base template. One base template for the mobile HTML, and one for the website HTML.
One solution is to wrap the render_to_response and determine which HTML to render, but I'd still have two files.
Is there a way I c...
With an extreme amount of SO user help, I used ASP.NET MVC 2 Futures to employ JSON to load 600 some products and display them with Microsoft Jquery templates in 400ms with the code below.
Is there a way to use Microsoft JQuery Linking to bind the object to the generated form data without looping through every one? (Assuming I preserve...