From 922d7f6c96f81a33538900f8a8992a5b6f640874 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 23 Apr 2020 02:00:05 +0800 Subject: ... --- include/cru/platform/graph_base.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/cru/platform') diff --git a/include/cru/platform/graph_base.hpp b/include/cru/platform/graph_base.hpp index 0b997770..c880c7a2 100644 --- a/include/cru/platform/graph_base.hpp +++ b/include/cru/platform/graph_base.hpp @@ -229,6 +229,15 @@ struct TextRange final { gsl::index GetEnd() const { return position + count; } + TextRange Normalize() const { + auto result = *this; + if (result.count < 0) { + result.position += result.count; + result.count = -result.count; + } + return result; + } + gsl::index position = 0; gsl::index count = 0; }; -- cgit v1.2.3