Skip to content

Commit

Permalink
COMP: Fix VS2015 TypeList.h(539): error C2059: syntax error: 'template'
Browse files Browse the repository at this point in the history
Add a workaround for Visual Studio < 2017, to avoid VS2015 compile errors when building with OpenCL, reported by Denis (@dpshamonin):

> TypeList.h(539): error C2059: syntax error: 'template'

Partially reverts "COMP: fixed the VisitDimension OpenCL compilation issues" commit c926163 (@dpshamonin Mar 5, 2019).
  • Loading branch information
N-Dekker committed Oct 19, 2019
1 parent 419313e commit 84acd94
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions Common/TypeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
#ifndef __TypeList_H__
#define __TypeList_H__

#ifndef ELX_TEMPLATE_WORKAROUND
# ifdef _MSC_VER
# if _MSC_VER < 1910 // Before MSVC++ 14.1 (Visual Studio 2017 version 15.0)
# define ELX_TEMPLATE_WORKAROUND
# else
# define ELX_TEMPLATE_WORKAROUND template
# endif
# else
# define ELX_TEMPLATE_WORKAROUND template
# endif
#endif

namespace typelist
{

Expand Down Expand Up @@ -485,9 +497,9 @@ struct Visit
{
typedef typename TTypeList::Head Head;
typedef typename TTypeList::Tail Tail;
visitor.template operator()< Head >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< Head >( );
Visit< Tail > next;
next.template operator()< Predicate >( visitor );
next.ELX_TEMPLATE_WORKAROUND operator()< Predicate >( visitor );
}


Expand All @@ -496,9 +508,9 @@ struct Visit
{
typedef typename TTypeList::Head Head;
typedef typename TTypeList::Tail Tail;
visitor.template operator()< Head >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< Head >( );
Visit< Tail > next;
next.template operator()< Predicate >( visitor );
next.ELX_TEMPLATE_WORKAROUND operator()< Predicate >( visitor );
}


Expand Down Expand Up @@ -536,9 +548,9 @@ struct VisitDimension
{
typedef typename TTypeList::Head Head;
typedef typename TTypeList::Tail Tail;
visitor.template operator()< Head, Dimension >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< Head, Dimension >( );
VisitDimension< Tail, Dimension > next;
next.template operator()< Predicate >( visitor );
next.ELX_TEMPLATE_WORKAROUND operator()< Predicate >( visitor );
}


Expand All @@ -547,9 +559,9 @@ struct VisitDimension
{
typedef typename TTypeList::Head Head;
typedef typename TTypeList::Tail Tail;
visitor.template operator()< Head, Dimension >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< Head, Dimension >( );
VisitDimension< Tail, Dimension > next;
next.template operator()< Predicate >( visitor );
next.ELX_TEMPLATE_WORKAROUND operator()< Predicate >( visitor );
}


Expand Down Expand Up @@ -592,15 +604,15 @@ struct DualVisit
void operator()( Visitor & visitor ) const
{
DualVisitImpl< TLeftTypeList, TRightTypeList > impl;
impl.template operator()< Visitor >( visitor );
return impl.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


template< typename Visitor >
void operator()( const Visitor & visitor ) const
{
DualVisitImpl< TLeftTypeList, TRightTypeList > impl;
impl.template operator()< Visitor >( visitor );
return impl.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


Expand Down Expand Up @@ -631,7 +643,7 @@ struct DualVisitImpl
goRight.visitRHS< Visitor >( visitor );

DualVisitImpl< LeftTail, TRightTypeList > goLeft;
goLeft.template operator()< Visitor >( visitor );
goLeft.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


Expand All @@ -644,7 +656,7 @@ struct DualVisitImpl
goRight.visitRHS< Visitor >( visitor );

DualVisitImpl< LeftTail, TRightTypeList > goLeft;
goLeft.template operator()< Visitor >( visitor );
goLeft.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


Expand All @@ -655,10 +667,10 @@ struct DualVisitImpl
typedef typename TRightTypeList::Head RightHead;
typedef typename TRightTypeList::Tail RightTail;

visitor.template operator()< LeftHead, RightHead >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< LeftHead, RightHead >( );

DualVisitImpl< TLeftTypeList, RightTail > goRight;
goRight.template visitRHS< Visitor >( visitor );
goRight.ELX_TEMPLATE_WORKAROUND visitRHS< Visitor >( visitor );
}


Expand All @@ -669,10 +681,10 @@ struct DualVisitImpl
typedef typename TRightTypeList::Head RightHead;
typedef typename TRightTypeList::Tail RightTail;

visitor.template operator()< LeftHead, RightHead >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< LeftHead, RightHead >( );

DualVisitImpl< TLeftTypeList, RightTail > goRight;
goRight.template visitRHS< Visitor >( visitor );
goRight.ELX_TEMPLATE_WORKAROUND visitRHS< Visitor >( visitor );
}


Expand Down Expand Up @@ -735,15 +747,15 @@ struct DualVisitDimension
void operator()( Visitor & visitor ) const
{
DualVisitDimensionImpl< TLeftTypeList, TRightTypeList, Dimension > impl;
impl.template operator()< Visitor >( visitor );
return impl.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


template< typename Visitor >
void operator()( const Visitor & visitor ) const
{
DualVisitDimensionImpl< TLeftTypeList, TRightTypeList, Dimension > impl;
impl.template operator()< Visitor >( visitor );
return impl.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


Expand Down Expand Up @@ -774,7 +786,7 @@ struct DualVisitDimensionImpl
goRight.visitRHS< Visitor >( visitor );

DualVisitDimensionImpl< LeftTail, TRightTypeList, Dimension > goLeft;
goLeft.template operator()< Visitor >( visitor );
goLeft.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


Expand All @@ -787,7 +799,7 @@ struct DualVisitDimensionImpl
goRight.visitRHS< Visitor >( visitor );

DualVisitDimensionImpl< LeftTail, TRightTypeList, Dimension > goLeft;
goLeft.template operator()< Visitor >( visitor );
goLeft.ELX_TEMPLATE_WORKAROUND operator()< Visitor >( visitor );
}


Expand All @@ -798,10 +810,10 @@ struct DualVisitDimensionImpl
typedef typename TRightTypeList::Head RightHead;
typedef typename TRightTypeList::Tail RightTail;

visitor.template operator()< LeftHead, RightHead, Dimension >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< LeftHead, RightHead, Dimension >( );

DualVisitDimensionImpl< TLeftTypeList, RightTail, Dimension > goRight;
goRight.template visitRHS< Visitor >( visitor );
goRight.ELX_TEMPLATE_WORKAROUND visitRHS< Visitor >( visitor );
}


Expand All @@ -812,10 +824,10 @@ struct DualVisitDimensionImpl
typedef typename TRightTypeList::Head RightHead;
typedef typename TRightTypeList::Tail RightTail;

visitor.template operator()< LeftHead, RightHead, Dimension >( );
visitor.ELX_TEMPLATE_WORKAROUND operator()< LeftHead, RightHead, Dimension >( );

DualVisitDimensionImpl< TLeftTypeList, RightTail, Dimension > goRight;
goRight.template visitRHS< Visitor >( visitor );
goRight.ELX_TEMPLATE_WORKAROUND visitRHS< Visitor >( visitor );
}


Expand Down

0 comments on commit 84acd94

Please sign in to comment.