I want to specialize a class template with the following function:
template <typename T>
class Foo
{
public:
static int bar();
};
The function has no arguments and shall return a result based on the type of Foo. (In this toy example, we return the number of bytes of the type, but in the actual application we want to return some me...
Hi, I'm sure that it is possible but I just can't do it, which is: How can I define function template inside non-template class? I tryied something like this:
class Stack_T
{
private:
void* _my_area;
static const int _num_of_objects = 10;
public:
/*
Allocates space for objects added to stack
*/
explicit Stack_T(size_t);
/*
Puts object o...
Im learning a lot about how MVC frameworks work by looking around and studying existing ones. It seems that every framework I see has a layout where each method in each controller has its own template file. So there will be a login template, a logout template, register, so on and so on.
My question is, how and why would you create a tem...
I have a question regarding how to elegantly override an arbitrary element deep inside a control's visual tree. I also have attempted to resolve it in a few different ways, but I've run into several problems with each. Usually when I try three different paths and fail at each one I go downstairs, have a coffee, and ask someone smarter ...
Consider the following code:
template<class T, class F> struct X {};
template<class T, class F, T F::* m> struct Y {};
struct Foo {
int member;
typedef X<int, Foo> x_type; // works well
typedef Y<int, Foo, &Foo::member> y_type; // ERROR
};
typedef Y<int, Foo, &Foo::member> y_type2; // OK
Why does ...
Is it possible to make this work?
template<class T>
fun(T * t) { t->someMemberFunc(); }
... somewhere in the code:
ManagedType ^ managedP = gcnew ManagedType();
UnmanagedType * unmanagedP = new UnmanagedType();
fun(managedP);
...
Hi,
I have a very silly problem with the code shown below.
The goal is to increment multiple counters at once, and have their value printed after being processed by a provided functor.
However g++ complains :
test.hpp:32: error: expected `;' before 'it' "
I tried to add some typedef, but the error message remains. Here is the code (...
As you probably know, starting from Rails 2.2, Rails is shipped with a simple localization and internationalization backend.
By default, you can store the strings you need to translate in the localization files within the config folder.
config/locales/en.yml
config/locales/it.yml
But Rails provides the ability to localize templates a...
Hiya,
I am familiar with theming and using template hints in the Magento back office to locate .phtml files.
What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model
What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.
I basically want to amend som...
Hi, I just read this article at Smashing Magazine (http://www.smashingmagazine.com/2009/11/21/zen-coding-a-new-way-to-write-html-code/) about Zen Code. Maybe there is any jQuery plugin for this? Might be good for json data inserting/templating.
...
I just found that when it comes to templates this code compiles in g++ 3.4.2 and works unless m() is not called:
template <typename T>
class C
{
T e;
public:
C(): e(0) {};
void m()
{
e = 0;
};
};
Now one may create and use instance
C<const int> c;
Until c.m() is not called there are no compile errors b...
Is there equivalent of <? extends T> <? super T> in c++?
Also, does <? extends T> <? super T> work even if T is an interface in Java?
...
After I set a session object, how can I access the value of the given object in my templates?
...
I have a template class
template <class T>
class myClass
{
public:
/* functions */
private:
typename T::Indices myIndices;
};
Now in my main code I want to instantiate the template class depending on a condition. Like :
myFunc( int operation)
{
switch (operation) {
case 0:
// Ins...
I am struggling to find out why I can't get transform to work with a template class.
Here's a simplified version of the template class :
template<typename T>
class base
{
public :
base() : all_() {}
~base() {}
public:
bool add(T t)
{
typename vector<T>::iterator itr
= lower_bound(all_.begin(), all_.end(), t);
i...
Hello all,
I'm trying to write an implementation of a 2-3-4 tree in c++. I'm it's been a while since I've used templates, and I'm getting some errors. Here's my extremely basic code framework:
node.h:
#ifndef TTFNODE_H
#define TTFNODE_H
template <class T>
class TreeNode
{
private:
Tre...
I am trying to create a list object, with the iterator class nested inside to understand how it works.
In some method, I am trying to return an iterator object but it doesn't work.
I created an example to show the problem :
// CLASS A
template <class T>
class A
{
public:
class B;
A(){}
};
// CLASS B
template <class T>
cla...
Hello! I'm trying to implement a method for a binary tree which returns a stream. I want to use the stream returned in a method to show the tree in the screen or to save the tree in a file:
These two methods are in the class of the binary tree:
Declarations:
void streamIND(ostream&,const BinaryTree<T>*);
friend ostream& operator<<(ost...
Hello all. I know this is probably a first year question, but I'm having some problems with templates and I haven't found a suitable answer yet. I'm trying to instantiate a new templated class like so:
TreeNode <T>newLeft = new TreeNode(root->data[0]);
Which is refering to a constructor which looks like:
template <class T>
//paramert...
How do I display thumbnails for my item list....also is it possible to display just a specific thumbnail or a random thumbnail? So far I have this in my template:
{% for p in item.images.all %}
{{ p.get_thumbnail.url }}
{% endfor %}
...