Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workarounds for clang-cl #87

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/factory/PVDataCreateFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using std::min;

namespace epics { namespace pvData {


#if ! (defined(__clang__) && defined(_MSC_VER))
template<> const ScalarType PVBoolean::typeCode = pvBoolean;
template<> const ScalarType PVByte::typeCode = pvByte;
template<> const ScalarType PVShort::typeCode = pvShort;
Expand All @@ -56,7 +56,7 @@ template<> const ScalarType PVULongArray::typeCode = pvULong;
template<> const ScalarType PVFloatArray::typeCode = pvFloat;
template<> const ScalarType PVDoubleArray::typeCode = pvDouble;
template<> const ScalarType PVStringArray::typeCode = pvString;

#endif

template<typename T>
PVScalarValue<T>::~PVScalarValue() {}
Expand Down
42 changes: 41 additions & 1 deletion src/pv/pvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include <iterator>
#include <iostream>
#include <iomanip>
#if defined(__clang__) && defined(_MSC_VER)
#include <type_traits>
#endif

#include <epicsAssert.h>

Expand Down Expand Up @@ -124,6 +127,36 @@ typedef std::tr1::shared_ptr<PVUnionArrayPtrArray> PVUnionArrayPtrArrayPtr;
class PVDataCreate;
typedef std::tr1::shared_ptr<PVDataCreate> PVDataCreatePtr;

#if defined(__clang__) && defined(_MSC_VER)
template <typename T>
constexpr ScalarType typeToCode() {
if (std::is_same<T, boolean>::value)
return pvBoolean;
else if (std::is_same<T, int8>::value)
return pvByte;
else if (std::is_same<T, uint8>::value)
return pvUByte;
else if (std::is_same<T, int16>::value)
return pvShort;
else if (std::is_same<T, uint16>::value)
return pvUShort;
else if (std::is_same<T, int32>::value)
return pvInt;
else if (std::is_same<T, uint32>::value)
return pvUInt;
else if (std::is_same<T, int64>::value)
return pvLong;
else if (std::is_same<T, uint64>::value)
return pvULong;
else if (std::is_same<T, float>::value)
return pvFloat;
else if (std::is_same<T, double>::value)
return pvDouble;
else if (std::is_same<T, std::string>::value)
return pvString;
}
#endif

/**
* @brief This class is implemented by code that calls setPostHander
*
Expand Down Expand Up @@ -383,7 +416,11 @@ class epicsShareClass PVScalarValue : public PVScalar {
typedef T* pointer;
typedef const T* const_pointer;

#if defined(__clang__) && defined(_MSC_VER)
constexpr static const ScalarType typeCode = typeToCode<T>();
#else
static const ScalarType typeCode;
#endif

/**
* Destructor
Expand Down Expand Up @@ -1184,8 +1221,11 @@ class epicsShareClass PVValueArray : public detail::PVVectorStorage<T,PVScalarAr
typedef ::epics::pvData::shared_vector<T> svector;
typedef ::epics::pvData::shared_vector<const T> const_svector;


#if defined(__clang__) && defined(_MSC_VER)
constexpr static const ScalarType typeCode = typeToCode<T>();
#else
static const ScalarType typeCode;
#endif

/**
* Destructor
Expand Down