Listing 8
class RecordInitializer
{
public:
template<class ReflectedClass> void
initReflectedMembers(ReflectedClass& initThis)
{
foreachAttribute(initThis,*this);
}
template<class ValueType, class NameTag, class Scope>
void operator()(ValueType& attribute, NameTag, Scope*)
{
initValue(attribute, IsPod<ValueType>::type());
}
private:
template<class Value> void initValue(Value& out,PodTag)
{
out = Value();
}
template<class Value> void initValue(Value& out,NoPodTag)
{/* no pod - no op*/}
};
struct PodTag{};
struct NoPodTag{};
template<class T> struct IsPod
{
enum {value = boost::is_pod<T>::value};
typedef typename boost::ct_if<(value != 0),PodTag,NoPodTag >::type type;
};