Hello guys,
at the moment I'm really interested in expression templates and want to code a library for writing and differentiating mathematical functions with a lambda-style syntax. At the moment, I'm able to write (_x * _x)(2); and get the correct result 4. But I would really like to do something like MathFunction f = _x * _x; f(2);, b...
I'm busy implementing a Graph ADT in C++. I have templates for the Edges and the Vertices. At each Vertex I have a vector containing pointers to the Edges that are incident to it. Now I'm trying to get an iterator over those edges. These are the lines of code:
vector<Edge<edgeDecor, vertexDecor, dir>*> edges = this->incidentEdges();
vec...
Why does the following give no compilation error?:
// T.h
template<class T> class X
{
public:
void foo(int a = 42);
};
// Main.cpp
#include "T.h"
#include <iostream>
template<class T> void X<T>::foo(int a = 13)
{
std::cout << a << std::endl;
}
int main()
{
X<int> x;
x.foo(); // prints 42
}
It seems as thoug...
I do a lot of prototyping and need more Xcode templates for the different classes of apps that I prototype. My current source of information for Xcode templates is a set of links from the web. What other resources do folks use for Xcode iPhone templates design and development?
...
Hello,
I'm trying to replicate a template I've used before with a member function, and it isn't going very well. The basic form of the function is
template<class T>
T Convert( HRESULT (*Foo)(T*))
{
T temp;
Foo(&temp); //Throw if HRESULT is a failure
return temp;
}
HRESULT Converter(UINT* val)
{
*val = 1;
return S_...
I have a class with static method which has a local static variable. I want that variable to be computed/evaluated once (the 1st time I call the function) and for any subsequent invocation, it is not evaluated anymore. How to do that? Here's my class:
template<
typename T1 = int, unsigned N1 = 1,
typename T2 = int, unsigned N2 =...
Hi my problem with Zend Framework...
unfortunately not solved after 3 hours of searching:
I have a modular Zend Application, which is working fine if i have my module and error templates in the called module.
If i delete error/error.phtml out of views/scripts/ a Fatal Error is showing up that there is no directory.
To cut a long story ...
I have an object:
POP_CULTURE_TYPES = (
('SG','Song'),
('MV', 'Movie'),
('GM', 'Game'),
('TV', 'TV'),
)
class Pop_Culture(models.Model):
name = models.CharField(max_length=30, unique=True)
type = models.CharField(max_length=2, choices = POP_CULTURE_TYPES, blank=True, null=True)
Then I have a function:
def...
Extends
Related
So, I'm trying to learn template metaprogramming better and I figure this is a good exercise for it.
I'm trying to write code that can callback a function with any number of arguments I like passed to it.
// First function to call
int add( int x, int y ) ;
// Second function to call
double square( double x ) ;
// T...
I have a template class like here (in a header) with a inner class and a static member of type pointer to inner class
template <class t> class outer {
class inner {
int a;
};
static inner *m;
};
template <class t> outer <t>::inner *outer <t>::m;
when i want to define that static member i says "error: expected con...
GCC seem to think that I am trying to make a function call in my template function signature. Can anyone please tell me what is wrong with the following?
227 template<class edgeDecor, class vertexDecor, bool dir>
228 vector<Vertex<edgeDecor,vertexDecor,dir>> Graph<edgeDecor,vertexDecor,dir>::vertices()
229 {
230 return V;
231 };
GCC i...
Hi, I have some complex types here so I decided to use nifty trick to have typedef on templated types. Then I have a class some_container that has a container as a member. Container is a vector of pairs composed of element and vector. I want to write std::find_if algorithm with lambda expression to find element that have certain value. T...
Why won't GCC allow a default parameter here?
template<class edgeDecor, class vertexDecor, bool dir>
Graph<edgeDecor,int,dir> Graph<edgeDecor,vertexDecor,dir>::Dijkstra(vertex s, bool print = false) const
{
This is the output I get:
graph.h:82: error: default argument given for parameter 2 of ‘Graph<edgeDecor, int, dir> Graph<edge...
I have a bunch of containers of object pointers that I want to iterate through in different contexts to produce diagnostics for them. I'm struggling with the syntax required to define the functions... which, on account of these objects filtering through diverse parts of my application, seem best encapsulated in a dedicated diagnostics cl...
I have Vertex template in vertex.h. From my graph.h:
20 template<class edgeDecor, class vertexDecor, bool dir>
21 class Vertex;
which I use in my Graph template.
I've used the Vertex template successfully throughout my Graph, return pointers to Vertices, etc. Now for the first time I am trying to declare and instantiate a Vertex obje...
Hi,
I have written a library for iPhone which is based upon some object models (whose definitions I get via XML). Now I have one implementation for a sample model ready but to make the code library generic I want to write an application where I can templatize the code and provide placeholders for data model specific points.
Is there an...
When I've got a template with certain type parameters, is it allowed for a function to return an object of this same template, but with different types? In other words, is the following allowed?
template<class edgeDecor, class vertexDecor, bool dir>
Graph<edgeDecor,int,dir> Graph<edgeDecor,vertexDecor,dir>::Dijkstra(vertex s, bool
prin...
When I specialize a (static) member function/constant in a template class, I'm confused as to where the declaration is meant to go.
Here's an example of what I what to do - yoinked directly from IBM's reference on template specialization:
===IBM Member Specialization Example===
template<class T> class X {
public:
static T v;
st...
Hi!
I want to include an initialized data structure in my request object, making it accessible in the context object from my templates. What I'm doing right now is passing it manually and tiresome within all my views:
render_to_response(...., ( {'menu': RequestContext(request)}))
The request object contains the key,value pair which i...
I have the following pattern:
template <int a, int b>
class MyClass
{
public:
template <int c>
MyClass<a, c> operator*(MyClass<b, c> const &other) const;
};
// ../..
template <int a, int b> template <int c>
MyClass<a, c> MyClass<a, b>::operator*(MyClass<b, c> const &other) const //< error here
{
MyClass<a, c> result;
// ..do s...