From dd80b127b4cdc2ba69dab1603449d53de20bfc97 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 11 Oct 2017 17:51:43 -0700 Subject: [PATCH] ircd::buffer: Fix the closure type so it's not too strict. --- include/ircd/buffer.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/ircd/buffer.h b/include/ircd/buffer.h index 505ae68d1..467dc0d5b 100644 --- a/include/ircd/buffer.h +++ b/include/ircd/buffer.h @@ -351,9 +351,9 @@ struct ircd::buffer::fixed_buffer :array_type{{0}} {} - fixed_buffer(const std::function &closure) + fixed_buffer(const std::function &closure) { - closure(mutable_raw_buffer{std::begin(*this), std::end(*this)}); + closure(mutable_buffer{reinterpret_cast(this->data()), this->size()}); } fixed_buffer(buffer b) @@ -363,6 +363,13 @@ struct ircd::buffer::fixed_buffer fixed_buffer() = default; }; +static_assert +( + // Assertion over an arbitrary but common template configuration. + std::is_standard_layout>::value, + "ircd::buffer::fixed_buffer must be standard layout" +); + /// Like unique_ptr, this template holds ownership of an allocated buffer /// ///