A
Alf P. Steinbach /Usenet
* Hicham Mouline, on 30.07.2010 12:03:
Like
template< class T >
struct DefaultConstructed
{
T v;
DefaultConstructed(): v() {}
};
Hm.
Cheers & hth.,
- Alf
Hello,
inside a template function, I need an instance of type T that is to be
default constructed.
I would normally write:
template<typename T>
void f(const T&) {
const T t();
}
This then requires T to have a default ctor, which is good.
However this doesn't work for primitive types where default ctor means
zeroing it.
Am I missing something obvious?
Like
template< class T >
struct DefaultConstructed
{
T v;
DefaultConstructed(): v() {}
};
I'm thinking of using type_traits
Hm.
Cheers & hth.,
- Alf