refs #345 Tuple tweaks to improve error messages.

This commit is contained in:
Mathew Sutcliffe
2014-11-07 23:35:52 +00:00
parent 8e5a9111bd
commit e436fa3870
2 changed files with 11 additions and 11 deletions

View File

@@ -239,9 +239,9 @@ namespace BlackMisc
* Can be used like <CODE> std::tie </CODE>. * Can be used like <CODE> std::tie </CODE>.
*/ */
//! @{ //! @{
static std::tuple<> toTuple(const T &object); static std::tuple<> toTuple(const T &object) = delete;
static std::tuple<> toTuple(T &object); static std::tuple<> toTuple(T &object) = delete;
static std::tuple<> constToTuple(const T &object); static std::tuple<> constToTuple(const T &object) = delete;
//! @} //! @}
/*! /*!
@@ -249,22 +249,22 @@ namespace BlackMisc
* \brief Returns a tuple of structs, each of which contains a reference to one of object's data members and its attched metadata. * \brief Returns a tuple of structs, each of which contains a reference to one of object's data members and its attched metadata.
*/ */
//! @{ //! @{
static std::tuple<> toMetaTuple(const T &object); static std::tuple<> toMetaTuple(const T &object) = delete;
static std::tuple<> toMetaTuple(T &object); static std::tuple<> toMetaTuple(T &object) = delete;
//! @} //! @}
/*! /*!
* \name Static Private Member Functions * \name Static Private Member Functions
* \brief Returns an object with information extracted from the stringified macro argument. * \brief Returns an object with information extracted from the stringified macro argument.
*/ */
static const Parser &parser(); static const Parser &parser() = delete;
/*! /*!
* \name Static Private Member Functions * \name Static Private Member Functions
* \brief Returns a list of the names of the tuple members. * \brief Returns a list of the names of the tuple members.
* \deprecated This information is now embedded in the meta tuples. * \deprecated This information is now embedded in the meta tuples.
*/ */
static const QStringList &jsonMembers(); static const QStringList &jsonMembers() = delete;
}; };
// Needed so that our qHash overload doesn't hide the qHash overloads in the global namespace. // Needed so that our qHash overload doesn't hide the qHash overloads in the global namespace.
@@ -402,7 +402,7 @@ namespace BlackMisc
QJsonObject serializeJson(std::tuple<Ts...> tu) QJsonObject serializeJson(std::tuple<Ts...> tu)
{ {
QJsonObject json; QJsonObject json;
Private::assertMeta<std::tuple<Ts...>>(); Private::assertMeta(tu);
Private::TupleHelper::serializeJson(json, tu, Private::skipFlaggedIndices<TupleConverterBase::DisabledForJson>(tu)); Private::TupleHelper::serializeJson(json, tu, Private::skipFlaggedIndices<TupleConverterBase::DisabledForJson>(tu));
return json; return json;
} }
@@ -414,7 +414,7 @@ namespace BlackMisc
template <class... Ts> template <class... Ts>
void deserializeJson(const QJsonObject &json, std::tuple<Ts...> tu) void deserializeJson(const QJsonObject &json, std::tuple<Ts...> tu)
{ {
Private::assertMeta<std::tuple<Ts...>>(); Private::assertMeta(tu);
Private::TupleHelper::deserializeJson(json, tu, Private::skipFlaggedIndices<TupleConverterBase::DisabledForJson>(tu)); Private::TupleHelper::deserializeJson(json, tu, Private::skipFlaggedIndices<TupleConverterBase::DisabledForJson>(tu));
} }

View File

@@ -163,9 +163,9 @@ namespace BlackMisc
// Compile-time assert for functions which require a meta tuple // Compile-time assert for functions which require a meta tuple
template <class Tu> template <class Tu>
struct assertMeta { static_assert(std::is_void<Tu>::value, "Function expected a meta tuple, got a value tuple"); }; void assertMeta(const Tu &) { static_assert(std::is_void<Tu>::value, "Function expected a meta tuple, got a value tuple"); }
template <class... Ts, qint64... Fs> template <class... Ts, qint64... Fs>
struct assertMeta<std::tuple<Attribute<Ts, Fs>...>> {}; void assertMeta(const std::tuple<Attribute<Ts, Fs>...> &) {}
// Convert a meta tuple to a value tuple // Convert a meta tuple to a value tuple
template <class Tu, size_t... Is> template <class Tu, size_t... Is>