pans
2017-08-09 c4019f7916b6e148e3f9a0e3c7dece422d78c342
VisitFace/RtspNativeCodec/app/libs/capnproto/include/capnp/schema.h
@@ -599,6 +599,8 @@
  template <typename T>
  inline static Type from();
  template <typename T>
  inline static Type from(T&& value);
  inline schema::Type::Which which() const;
@@ -679,6 +681,9 @@
  }
  void requireUsableAs(Type expected) const;
  template <typename T, Kind k>
  struct FromValueImpl;
  friend class ListSchema;  // only for requireUsableAs()
};
@@ -899,6 +904,29 @@
template <typename T>
inline Type Type::from() { return Type(Schema::from<T>()); }
template <typename T, Kind k>
struct Type::FromValueImpl {
  template <typename U>
  static inline Type type(U&& value) {
    return Type::from<T>();
  }
};
template <typename T>
struct Type::FromValueImpl<T, Kind::OTHER> {
  template <typename U>
  static inline Type type(U&& value) {
    // All dynamic types have getSchema().
    return value.getSchema();
  }
};
template <typename T>
inline Type Type::from(T&& value) {
  typedef FromAny<kj::Decay<T>> Base;
  return Type::FromValueImpl<Base, kind<Base>()>::type(kj::fwd<T>(value));
}
inline bool Type::isVoid   () const { return baseType == schema::Type::VOID     && listDepth == 0; }
inline bool Type::isBool   () const { return baseType == schema::Type::BOOL     && listDepth == 0; }
inline bool Type::isInt8   () const { return baseType == schema::Type::INT8     && listDepth == 0; }