You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2017/03/04 17:17:42 UTC
[trafficserver] branch master updated: MemView: Add constructor
with 'int' size for convenience.
This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new adf7b1a MemView: Add constructor with 'int' size for convenience.
adf7b1a is described below
commit adf7b1a61afed342def855a5c5dcf4ab14b051d6
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Sat Mar 4 11:17:17 2017 -0600
MemView: Add constructor with 'int' size for convenience.
---
lib/ts/MemView.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/ts/MemView.h b/lib/ts/MemView.h
index ce6e41a..fa9837f 100644
--- a/lib/ts/MemView.h
+++ b/lib/ts/MemView.h
@@ -321,6 +321,14 @@ public:
size_t n ///< Size of buffer.
);
+ /** Construct explicitly with a pointer and size.
+ If @a n is negative it is treated as 0.
+ @internal Overload for convience, otherwise get "narrow conversion" errors.
+ */
+ constexpr StringView(const char *ptr, ///< Pointer to buffer.
+ int n ///< Size of buffer.
+ );
+
/** Construct from a half open range of two pointers.
@note The byte at @start is in the view but the byte at @a end is not.
*/
@@ -858,6 +866,9 @@ inline constexpr StringView::StringView()
inline constexpr StringView::StringView(const char *ptr, size_t n) : _ptr(ptr), _size(n)
{
}
+inline constexpr StringView::StringView(const char *ptr, int n) : _ptr(ptr), _size(n < 0 ? 0 : n)
+{
+}
inline constexpr StringView::StringView(const char *start, const char *end) : _ptr(start), _size(end - start)
{
}
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].