diff --git a/MSVC/1200/DataGenerators.h b/MSVC/1200/DataGenerators.h new file mode 100644 index 0000000..2c67977 --- /dev/null +++ b/MSVC/1200/DataGenerators.h @@ -0,0 +1,143 @@ +//////////////////////////////////////////////////////////////////////////////// +// The Loki Library +// Data Generator by Shannon Barber +// This code DOES NOT accompany the book: +// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design +// Patterns Applied". Copyright (c) 2001. Addison-Wesley. +// +// Code covered by the MIT License +// The author makes no representations about the suitability of this software +// for any purpose. It is provided "as is" without express or implied warranty. +//////////////////////////////////////////////////////////////////////////////// + +// Last update: Mar 04, 2003 +// MSVC 6.0 version + +#ifndef DATAGENERATORS_H +#define DATAGENERATORS_H +#include "Typelist.h" +#include "MSVC6Helpers.h" +namespace Loki +{ + namespace TL + { + template + struct nameof_type + { + const char* operator()() + { + return typeid(T).name(); + } + }; + template + struct sizeof_type + { + size_t operator()() + { + return sizeof(T); + } + }; + + // wrappers to workaround the need for template template parameters + struct nameof_type_wrapper + { + template + struct In + { + typedef nameof_type type; + }; + }; + + struct sizeof_type_wrapper + { + template + struct In + { + typedef sizeof_type type; + }; + + }; + template + struct IterateTypes; +namespace Private +{ + // Specialization for a general typelist + template + struct IterateTypesImpl + { + template + struct In + { + typedef typename TList::Head T1; + typedef typename TList::Tail T2; + + typedef IterateTypes head_t; + head_t head; + typedef IterateTypes tail_t; + tail_t tail; + + template + void operator()(II ii) + { + head.operator()(ii); + tail.operator()(ii); + } + }; + }; + + // Specialization for a single type + template <> + struct IterateTypesImpl + { + template + struct In + { + template + void operator()(II ii) + { + typedef typename Loki::ApplyInnerType::type gFunc; + gFunc genfunc; + *ii = genfunc(); + ++ii; //Is this even needed? + } + }; + }; + + // Specialization for NullType + template <> + struct IterateTypesImpl + { + template + struct In + { + template + void operator()(II ii) + {} + }; + }; +} // end ns Private + + template + struct IterateTypes : public + Private::IterateTypesImpl + < + TL::Private::IsTypelist::type_id + >::template In + {}; + + template + void iterate_types(II ii) + { + Loki::TL::IterateTypes it; + it(ii); + } + }//ns TL +}//ns Loki + +#endif //DATAGENERATORS_H +//////////////////////////////////////////////////////////////////////////////// +// Change log: +// 9/20/02 Named changed from GenData to IterateTypes +// 10/8/02 insertion iterators are passed-by-value, not by-reference (oops) +// 03/04/03 ported by Benjamin Kaufmann to MSVC 6.0 +////////////////////////////////////////////////////////////////////////////////