I'm trying to write a function to "stringify" parameters for logging purpose. For example, I'd like to write something like this:
vector<string> queries;
set<uint_8> filters;
LOG(INFO) << stringify<vector, string>(queries);
LOG(INFO) << stringify<set, uint_8>(filters);
Here is the function template I wrote:
template <typename contai...
There is a top-level template in my project and it defines several sub-templates nested in a form:
<h:form>
<ui:insert name="header"/>
<ui:insert name="leftbar"/>
<ui:insert name="maincontent"/>
</h:form>
It's not my idea actually to build application in this way. I see both its advantages and disadvantages.
The biggest p...
I have a WCF service to publish feeds and atom. The tricky things is need to publish password protected feeds that too passing userid and password along with URL.
Since WCF REST support bindbyposition and bindbyparameter name, just i would like to know how to allow & extract userid and password from webget url into wcf service.
Please ...
I'm trying to create a list of objects, where each object also stores 'ownership' - ie, it knows which list holds it.
In a non-template situation, it's straightforward:
class FooList; // forward declaration
class FooItem
{
public:
FooList *owner;
...
};
class FooList: private std::list<FooItem>
{
...
};
However, the lis...
Possible Duplicate:
g++ is not a type error
The following does not compile:
1 template<typename T>
2 void foo(std::vector<T>::iterator & i)
3 {
4 }
On Visual Studio, I get the following errors:
>(2) error C2065: 'i' : undeclared identifier
>(4) warning C4346: 'std::vector<_Tp>::iterator' : dependent name is ...
How can I use a static function pointer member in my class template?
I'm working with C++ in Visual Studio, and my code looks similar to the following:
template<typename T>
class ClassTemplate
{
public:
static T* CallIt() { return ClassTemplate<T>::mFunctionPointer(); }
private:
static T* (*mFunctionPointer)();
};
When I com...
Hi there!
I got a little problem with templates:
template <typename T>
T Func(){
std::string somestr = "";
// somestr = ...
if (somestr != ""){
return boost::lexical_cast<T>(somestr);
}
else{
T ret; // warning: "ret may be uninitialized in this function"
return ret;
}
}
If this functio...
I cant figure out how to specialize partially this template. compiler complains that template parameter N is not used in partial specialization
#include <boost/multi_array.hpp>
template<typename T, class A>
struct adaptable;
template<typename T, size_t N>
struct adaptable<T,
// line below is the problem
...
Aight, basically, I have a database that looks like this:
id | parentid | type | name
---------------------------------------------
1 | 0 | heading | this is my heading
---------------------------------------------
2 | 1 | child | this is one of many child elements
I'm using Mako to go through that list of data an...
I am not sure if title makes sense.
let me explain what I want to do:
I have template constructor, the argument generally must be reference, but can be value in certain cases.
Ultimately, I would like to have something like:
matrix_adapter(typename adaptable<T,A>::type);
where adaptable<T,A>::type can either be value or reference de...
Sometimes I need to use the same html code in different templates, like:
<div class="mylist"><span>item-1</span><span>item-2</span>...</div>
or more complicated widgets. I'm new to Django so I want to learn what do you usually do in these kinds of situations? Do you create your own template tags or what?
...
What (preferably stable releases) alternatives exist to ERB and HAML for creating a HTML template parser with Ruby?
I would really love something like Django templates implemented in Ruby.
...
I've the below code,
template< typename T >
class T1 {
public:
T i;
protected:
T j;
private:
T k;
friend void Test();
};
The above code has a template class T1 with three members i,j and k and a friend function Test(),
I just want to know that which member/s of T1 will be available in function Test()?
Any help in t...
I have ClassA<ARG_TYPE> and ClassB<ARG_TYPE>. Now I want want to use ClassC, that has common ARG_TYPE and mentioned classes as template arguments.
ClassC<ARG_TYPE, ClassA<ARG_TYPE>, ClassB<ARG_TYPE>> is easy.
But is it possible do declare ClassC<ARG_TYPE, ClassA, ClassB> so that both A and B classes would know to use ARG_TYPE as their...
My question is related to this question.
#include<iostream>
template< typename T >
class T1 {
public:
T i;
void display()
{
std::cout<<i<<"\n"<<j<<"\n"<<k;
}
protected:
T j;
private:
T k;
friend void Test( T1 &obj);
};
template<typename T>
void Test(T1<T> &obj)
{
T a=T();
obj.i=a;
obj.j=a;
...
I have a landing page created as a single html file with an external css file and a bunch of jpeg images. It looks fine and everything is good with it. I need to insert this page as an article in Joomla so that it looked the same way as it does now, without broken styles and missing images. It should show all header, footer and sidebar c...
How can i compile the below code without changing the status of int data?
template<typename U>
void Test(U);
template< class T >
class B {
int data;
public:
friend void Test<>( T );
};
template<typename U>
void Test(U u) {
B < int> b1;
b1.data = 7;
}
int main(int argc, char *argv[])
{
char i;
Test(i);
...
Reading C++ Templates: The Complete Guide and it says
Note that templates cannot be declared
in a function
It does not give explanation and/or cross reference to any other chapter in the book or external resource.
Could someone help in explaining this. Probably it is explained later in the book but not there yet. If explained ...
The standard template for a node in Drupal is node.tpl.php
It's possible to call a different template for a content-type, like 'newsitem'. You will call it like this : node-newsitem.tpl.php.
I was wondering if there's a way to call a specific Node ID? node-34.tpl.php does not work.
Thanks
...
I have a rails 3 template handler and would like to configure it not to use the layout. In rails2 we would do a
::ActionController::Base.exempt_from_layout :extension_name
But this method does not exist in Rails 3 any more. I did not find a place within the code where there is an option for a template engine not to run through...