Hello!
I wish to have a non-template class with a template constructor with no arguments.
As far as I understand, it's impossible to have it (because it would conflict with the default constructor - am I right?), and the workaround is the following:
class A{
template <typename U> A(U* dummy) {
// Do something
}
};
Maybe the...
This code fragment:
namespace ns
{
struct last;
struct first
{
typedef last next;
};
template <typename T>
struct chain
{
chain<typename T::next> next;
};
template <>
struct chain<last>
{
};
}
using namespace ns;
template <typename T>
void f(const T& x) // #1
...
Is it possible to store a templated class like
template <typename rtn, typename arg>
class BufferAccessor {
public:
int ThreadID;
virtual rtn do_work(arg) = 0;
};
BufferAccessor<void,int> access1;
BufferAccessor<int,void> access2;
in the same container like a vector or list
edit:
The purpose for this is I am trying to ...
Hello!
I wish to know if it's possible in C++ to somehow handle the following situations:
Situation 1) (Easily handled)
class BasicFacility { }
template <typename U1, typename U2> class Facility : public BasicFacility { }
Suppose now that we want to have some compilation-time assertion and we want to check if the arbitrary type ty...
If you have this generic function:
template<class type, class ret, class atype1, class atype2, class atype3>
ret call3(type *pClass, ret(type::* funcptr)(atype1, atype2, atype3), atype1 arg, atype2 arg2, atype3 arg3)
{
//do some stuff here
return (pClass->*funcptr)(arg, arg2, arg3);
}
and you do this:
class MyClass
{
public...
I've just starting using JAutodoc which is really rather nice. I'm now customizing the output and was wondering if its possible to customize the type comment based on the name of the type. Essentially, I'm looking to have one comment for JUnit test classess (whose class names all begin "Test...") and another type comment for non unit t...
Hi there.
I am a final year engineering student. Me and my friends have decided that our final year project would be "Simulation of Turing Machine using Template Metaprogramming".
I understand what "Turing Machine" and "Template Metaprogramming" are but my question is why the simulation would be tedious if we design the Turing Machine ...
I would like to create a base class that will be inherited by other objects so that they can be stored in the same container. This base class will contain a templated method that defines the fuction as a setter or getter used for accessing a buffer in a multithreaded system. I want to do something like this guy did but not really sure ...
There are a huge feature collection in C++ programming language that supply a strict control over datatypes. Frequently one would mold his code with template system to achieve the most adequate functionality while guaranteeing within it correct type preservation and flexibility in its manipulation. Less frequently enumerations are used f...
Hello everyone ;)
I'm developing a website and I want to use PHPBB auth system. I managed to get it working pretty well, following a few suggestions I found on this website, but I've got a problem.
Basically all I need to do is accessing template variables such as {U_PROFILE}, {L_PROFILE}, {U_PRIVATEMSGS}, {PRIVATE_MESSAGE_INFO} and othe...
I have ListBox and i need set background "Transparent".
I've selected in red, then that should be transparent:
style ListBox, ListBoxItem, ScrollViewer and ScrollBar:
<Style TargetType="{x:Type ScrollBar}">
<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Sta...
Hello,
I get no binding errors and this code works at another place. I haven`t found out yet what I do now differently to the code where it works and its not that much code.
In UserControl.Resource:
<Style TargetType="TextBox">
<Setter Property="BorderBrush" Value="DarkBlue"/>
<Setter Property="BorderThickness" Value="1" />
...
Hi,
Is it possible in media wiki to before hand create fixed number of pages under categories and subcategories, so that users can come and just enter data for those pages. No user is allowed to create pages, categories and subcategories. Also do we have custom templates for mediawiki which we can just install and get going.
Thanks
...
I'm looking for a hybrid meta-container/container class. I want a class that maps a compile-time type to a runtime value. A code snippit is worth 1024 words so:
struct Foo { /* ... */ };
struct Bar { /* ... */ };
int main()
{
meta_container<Foo,float,int> mc;
mc.get<float>() = 1.0f;
mc.get<Foo>().method(blah);
mc.get<Bar>...
I need to define a template struct such that:
element<T>::type
is of type:
T::element_type
if T contains a (public) typedef named element_type, otherwise (if it does not contain such typedef)
element<T>::type
is of type
T::value_type
if T is mutable and of type
const T::value_type
if T is constant.
I am really strugglin...
hello!
I'm struggling with compile error C3200
http://msdn.microsoft.com/en-us/library/3xwxftta.aspx discusses the problem and gives as an example:
// C3200.cpp
template<typename T>
class X
{
};
template<template<typename U> class T1, typename T2>
class Y
{
};
int main()
{
Y<int, int> y; // C3200
}
and suggests that instead
...
Is it possible to have a templated class and also templating the constructor with some other type?
something like this:
template<typename T1>
class Foo{
template<typename T2>
Foo(T1 aBar, T2 dummyArgument){
bar = aBar;
bytesOfT2 = sizeof(T2);
};
int bytesOfT2;
T1 bar;
};
is this possible? and if s...
Hi!
let's say i want to have a member variable for a pointer to std::vector but i do not want to specify what type of variable it stores. I want to access only those functions that are independant of it's actual generic type. is this possible with c++? something like this:
class Foo{
public:
void setVec(std::vector* someVec){
...
To illustrate my question more clearly, let's suppose I have a include.html template with content:
{% block test_block %}This is include{% endblock %}
I have another template called parent.html with content like this:
This is parent
{% include "include.html" %}
Now I create a templated called child.html that extends parent.html:
...
Hi ,
template < int >
class CAT
{};
int main()
{
int i=10;
CAT<(const int)i> cat;
return 0; //here I got error: ‘i’ cannot appear in a constant-expression
}
even
int i=10;
const int j=i;
CAT<j> cat; //this still can not work
but I have convert i to const int ,why compiler...