I implemented a "discriminated union" capable of holding C++ types, even if they have destructors etc. I implemented this as a Russian doll; i.e. Union<T1, T2, T3> derives from unionNode<T1, <UnionNode<T2, UnionNode<T3, void> > > and UnionNode<T, Tail> derives from Tail. The specialization UnionNode<T, void> holds a void* which contains ...
Does anyone know why using-declarations don't seem to work for importing type names from dependent base classes? They work for member variables and functions, but at least in GCC 4.3, they seem to be ignored for types.
template <class T>
struct Base
{
typedef T value_type;
};
template <class T>
struct Derived : Base<T>
{
// Version...
Hello,
Today one of my friends told me that the following code compiles well on his Visual Studio 2008:
#include <vector>
struct A
{
static int const const_iterator = 100;
};
int i;
template <typename T>
void PrintAll(const T & obj)
{
T::const_iterator *i;
}
int main()
{
std::vector<int> v;
A a;
PrintAll(a);
PrintAll(v);
...
What is wrong with the following piece of code?
template<typename X>
struct A {
template<int N>
int foo() const {
return N;
}
};
template<typename X>
struct B {
int bar(const A<X>& v) {
return v.foo<13>();
}
};
#include <iostream>
using std::cout;
using std::endl;...