Merge pull request #144 from qsodev/fixpeektyp

fixed peektyp check and return value
This commit is contained in:
Constantin Rack 2017-08-17 21:12:28 +02:00 committed by GitHub
commit 8f56e3b522

View File

@ -341,9 +341,10 @@ public:
T peektyp(size_t index) T peektyp(size_t index)
{ {
static_assert(!std::is_same<T, std::string>::value, "Use peekstr() instead of peektyp<std::string>()"); static_assert(!std::is_same<T, std::string>::value, "Use peekstr() instead of peektyp<std::string>()");
if(sizeof(T) != m_parts.front().size()) if(sizeof(T) != m_parts[index].size())
throw std::runtime_error("Invalid type, size does not match the message size"); throw std::runtime_error("Invalid type, size does not match the message size");
T type = *m_parts[index].data<T>(); T type = *m_parts[index].data<T>();
return type;
} }
// Create multipart from type (fixed-size) // Create multipart from type (fixed-size)