view: add nodiscard to constant split operations

Any time we have a constant operator we need to warn the user if they
thing the operation is mutating and does not make use of the result.
This commit is contained in:
Danny Robson 2018-07-13 14:05:54 +10:00
parent a2e2d59c98
commit 493c91eace
2 changed files with 7 additions and 7 deletions

View File

@ -119,7 +119,7 @@ processor::process (
if (handler == m_directives.end ())
throw unknown_directive (head_string);
lines.consume (handler->second->process (os, ctx, {l, lines.end()}));
lines = lines.consume (handler->second->process (os, ctx, {l, lines.end()}));
}
return lines.end ();

View File

@ -265,7 +265,7 @@ namespace util {
//---------------------------------------------------------------------
constexpr std::tuple<
[[nodiscard]] constexpr std::tuple<
util::view<BeginT,BeginT>,
util::view<BeginT,EndT>
>
@ -279,7 +279,7 @@ namespace util {
//---------------------------------------------------------------------
constexpr auto
[[nodiscard]] constexpr auto
split (int pos) const
{
auto last = m_begin;
@ -293,7 +293,7 @@ namespace util {
// "abc".slice(0, 3) == "abc"
// "abc".slice(0, -1) == "abc"
// "abc".slice(0, -2) == "ab"
constexpr auto
[[nodiscard]] constexpr auto
slice (int a, int b) const
{
auto first = m_begin;
@ -307,7 +307,7 @@ namespace util {
//---------------------------------------------------------------------
constexpr auto
[[nodiscard]] constexpr auto
consume (int count) const
{
auto [a,b] = split (count);
@ -317,7 +317,7 @@ namespace util {
//---------------------------------------------------------------------
constexpr util::view<BeginT,EndT>
[[nodiscard]] constexpr util::view<BeginT,EndT>
consume (util::view<BeginT,BeginT> prefix) const
{
assert (prefix.begin () == begin ());
@ -325,7 +325,7 @@ namespace util {
}
constexpr util::view<BeginT,EndT>
[[nodiscard]] constexpr util::view<BeginT,EndT>
consume (const BeginT pos) const
{
return { pos, end () };