From df73241a60f564da95831fb0884ada49df85a060 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 27 Jul 2017 15:54:59 -0700 Subject: [PATCH] constexpr in derived buffers fix #657 --- CHANGELOG.md | 1 + include/boost/beast/core/flat_static_buffer.hpp | 14 ++++++++++++++ include/boost/beast/core/static_buffer.hpp | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b0cb6f6..f46b1b6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Version 91: * Tidy up namespace qualifiers * Tidy up MSVC CMakeLists.txt * Optimize buffered_read_stream +* constexpr in derived buffers WebSocket: diff --git a/include/boost/beast/core/flat_static_buffer.hpp b/include/boost/beast/core/flat_static_buffer.hpp index 489a512c..0f3ea3e0 100644 --- a/include/boost/beast/core/flat_static_buffer.hpp +++ b/include/boost/beast/core/flat_static_buffer.hpp @@ -235,6 +235,20 @@ public: { return *this; } + + /// Return the maximum sum of the input and output sequence sizes. + std::size_t constexpr + max_size() const + { + return N; + } + + /// Return the maximum sum of input and output sizes that can be held without an allocation. + std::size_t constexpr + capacity() const + { + return N; + } }; } // beast diff --git a/include/boost/beast/core/static_buffer.hpp b/include/boost/beast/core/static_buffer.hpp index 568cf2fe..c6c5d0eb 100644 --- a/include/boost/beast/core/static_buffer.hpp +++ b/include/boost/beast/core/static_buffer.hpp @@ -216,6 +216,20 @@ public: { return *this; } + + /// Return the maximum sum of the input and output sequence sizes. + std::size_t constexpr + max_size() const + { + return N; + } + + /// Return the maximum sum of input and output sizes that can be held without an allocation. + std::size_t constexpr + capacity() const + { + return N; + } }; } // beast