Tools and libraries to glue C/C++ APIs to high-level languages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

123 lines
3.1 KiB

#include "../Tests.h"
#include "AnotherUnit.h"
class DLL_API T1
{
};
class DLL_API T2
{
};
template <typename T>
class DLL_API IndependentFields : public T1
{
private:
int field;
};
template <typename T>
class DLL_API DependentValueFields
{
private:
T field;
union {
int unionField;
};
};
template <typename T>
class DLL_API DependentPointerFields
{
private:
T* field;
};
template <typename K, typename V>
class TwoTemplateArgs
{
private:
K key;
V value;
};
template <typename T, typename D = IndependentFields<T>>
class HasDefaultTemplateArgument
{
T field;
};
template <typename T>
class TemplateInAnotherUnit;
class DLL_API TemplateSpecializer
{
public:
TemplateSpecializer();
template <typename T>
class NestedTemplate
{
};
private:
IndependentFields<int> independentFields;
DependentValueFields<bool> dependentValueFields;
DependentPointerFields<int> dependentPointerFields;
HasDefaultTemplateArgument<int> hasDefaultTemplateArgument;
DependentValueFields<T1> dependentPointerFieldsT1;
DependentValueFields<T2> dependentPointerFieldsT2;
TemplateInAnotherUnit<float> templateInAnotherUnit;
DependentValueFields<IndependentFields<int>> specializeWithSpecialization;
DependentValueFields<IndependentFields<bool>> specializeWithSameSpecialization;
NestedTemplate<int> nestedTemplate;
DependentValueFields<DependentValueFields<int*>> nestedDependentPointer1;
DependentValueFields<DependentValueFields<char*>> nestedDependentPointer2;
DependentValueFields<char[3]> dependentFieldArray;
void completeSpecializationInParameter(DependentValueFields<float> p1,
DependentValueFields<int*> p2,
DependentValueFields<float*> p3);
void completeSpecializationInParameter(TwoTemplateArgs<int*, int*> p1,
TwoTemplateArgs<int*, int> p2,
TwoTemplateArgs<int*, float> p3);
};
template <typename Key, typename T>
class PartiallySpecialized
{
};
template <typename Key>
class PartiallySpecialized<Key, int>
{
union
{
int i;
float f;
};
};
template<class T>
class HasResultType {
typedef char Yes;
typedef void *No;
template<typename U> static Yes test(int, const typename U::result_type * = 0);
template<typename U> static No test(double);
public:
enum { Value = (sizeof(test<T>(0)) == sizeof(Yes)) };
};
template <typename Functor, bool foo = HasResultType<Functor>::Value>
struct LazyResultType { typedef typename Functor::result_type Type; };
template <typename Functor>
struct LazyResultType<Functor, false> { typedef void Type; };
template <class InputSequence, class MapFunctor>
struct MapResultType
{
typedef typename LazyResultType<MapFunctor>::Type ResultType;
};
template <template <typename> class InputSequence, typename MapFunctor, typename T>
struct MapResultType<InputSequence<T>, MapFunctor>
{
typedef InputSequence<typename LazyResultType<MapFunctor>::Type> ResultType;
};