summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-03-21 20:27:14 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2018-03-21 20:27:14 +0000
commit1811a870b7f10b5c58faae2848186f07bdbde6d8 (patch)
treec3937055a2f75f81a904a4600f359fd58be35300
parentAdd some nice cxxflags (diff)
downloadslicer-1811a870b7f10b5c58faae2848186f07bdbde6d8.tar.bz2
slicer-1811a870b7f10b5c58faae2848186f07bdbde6d8.tar.xz
slicer-1811a870b7f10b5c58faae2848186f07bdbde6d8.zip
Simplify typeRead/typeWrite by replacing enable_if with if constexpr
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h93
1 files changed, 40 insertions, 53 deletions
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index a2f2c62..149bb1d 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -56,81 +56,68 @@ namespace Slicer {
return ModelObject && mp->HasValue();
}
-#define IfLocal(T) \
- typename std::enable_if<Slicer::isLocal<T>::value>::type
-#define IfNotLocal(T) \
- typename std::enable_if<!Slicer::isLocal<T>::value>::type
-
template<typename T>
- IfNotLocal(T)
+ void
typeWrite(::Ice::OutputStreamPtr & s, const ::IceUtil::Optional<T> & m)
{
- typedef Ice::StreamableTraits<T> traits;
- typedef Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength> SOH;
- s->startEncapsulation();
- if (m && s->writeOptional(0, SOH::optionalFormat)) {
- SOH::write(s.get(), *m);
+ if constexpr (!Slicer::isLocal<T>::value) {
+ typedef Ice::StreamableTraits<T> traits;
+ typedef Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength> SOH;
+ s->startEncapsulation();
+ if (m && s->writeOptional(0, SOH::optionalFormat)) {
+ SOH::write(s.get(), *m);
+ }
+ s->endEncapsulation();
+ }
+ else {
+ throw LocalTypeException();
}
- s->endEncapsulation();
- }
-
- template<typename T>
- IfLocal(T)
- typeWrite(::Ice::OutputStreamPtr &, const ::IceUtil::Optional<T> &)
- {
- throw LocalTypeException();
}
template<typename T>
- IfNotLocal(T)
+ void
typeWrite(::Ice::OutputStreamPtr & s, const T & m)
{
- s->write(m);
- }
-
- template<typename T>
- IfLocal(T)
- typeWrite(::Ice::OutputStreamPtr &, const T &)
- {
- throw LocalTypeException();
+ if constexpr (!Slicer::isLocal<T>::value) {
+ s->write(m);
+ }
+ else {
+ throw LocalTypeException();
+ }
}
template<typename T>
- IfNotLocal(T)
+ void
typeRead(::Ice::InputStreamPtr & s, ::IceUtil::Optional<T> & m)
{
- typedef Ice::StreamableTraits<T> traits;
- typedef Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength> SOH;
- s->startEncapsulation();
- if (s->readOptional(0, SOH::optionalFormat)) {
- m.__setIsSet();
- SOH::read(s.get(), *m);
+ if constexpr (!Slicer::isLocal<T>::value) {
+ typedef Ice::StreamableTraits<T> traits;
+ typedef Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength> SOH;
+ s->startEncapsulation();
+ if (s->readOptional(0, SOH::optionalFormat)) {
+ m.__setIsSet();
+ SOH::read(s.get(), *m);
+ }
+ else {
+ m = IceUtil::None;
+ }
+ s->endEncapsulation();
}
else {
- m = IceUtil::None;
+ throw LocalTypeException();
}
- s->endEncapsulation();
- }
-
- template<typename T>
- IfLocal(T)
- typeRead(::Ice::InputStreamPtr &, ::IceUtil::Optional<T> &)
- {
- throw LocalTypeException();
}
template<typename T>
- IfNotLocal(T)
+ void
typeRead(::Ice::InputStreamPtr & s, T & m)
{
- s->read(m);
- }
-
- template<typename T>
- IfLocal(T)
- typeRead(::Ice::InputStreamPtr &, T &)
- {
- throw LocalTypeException();
+ if constexpr (!Slicer::isLocal<T>::value) {
+ s->read(m);
+ }
+ else {
+ throw LocalTypeException();
+ }
}
template<typename T>