Skip to content

Instantly share code, notes, and snippets.

@r2p2
Created July 2, 2010 23:16
Show Gist options
  • Save r2p2/462061 to your computer and use it in GitHub Desktop.
Save r2p2/462061 to your computer and use it in GitHub Desktop.
// g++ main2.cpp -std=gnu++0x
#include <vector>
#include <memory> // shared_ptr
template <class T>
class Base
{
public:
Base(T value)
:m_value(value)
{}
T value()
{
return m_value;
}
void value(T new_value)
{
m_value = new_value;
}
protected:
T m_value;
};
class Integer : public Base<int>
{
Integer(int new_value)
:Base<int>(new_value)
{}
};
class Wrapper
{
Wrapper(std::shared_ptr<Base<auto>> bptr)
:m_bptr(bptr)
{}
std::shared_ptr<Base<auto>> get()
{
return m_bptr;
}
private:
std::shared_ptr<Base<auto>> m_bptr;
};
int main() {
std::vector<Wrapper> list;
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment