aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Position.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-01-22 08:20:37 +1100
committerNeil <nyamatongwe@gmail.com>2018-01-22 08:20:37 +1100
commitcd628e62f21dc03bc8d62bf5c8bf1fd65d025dd2 (patch)
tree66a105ca800131d9c1aa7425cf1a6fbd02b163cb /src/Position.h
parentd1abca4bbafa9830544e8ec8ce0e4b5754d98c49 (diff)
downloadscintilla-mirror-cd628e62f21dc03bc8d62bf5c8bf1fd65d025dd2.tar.gz
Make clamp generic so can be used on more types.
Updated comments.
Diffstat (limited to 'src/Position.h')
-rw-r--r--src/Position.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/Position.h b/src/Position.h
index 258eb177f..166fc24da 100644
--- a/src/Position.h
+++ b/src/Position.h
@@ -11,6 +11,7 @@
/**
* A Position is a position within a document between two characters or at the beginning or end.
* Sometimes used as a character index where it identifies the character after the position.
+ * A Line is a document or screen line.
*/
namespace Sci {
@@ -18,14 +19,10 @@ namespace Sci {
typedef int Position;
typedef int Line;
-// A later version (4.x) of this file may:
-//#if defined(SCI_LARGE_FILE_SUPPORT)
-//typedef std::ptrdiff_t Position;
-// or may allow runtime choice between different position sizes.
-
const Position invalidPosition = -1;
-inline int clamp(int val, int minVal, int maxVal) {
+template <typename T>
+inline constexpr T clamp(T val, T minVal, T maxVal) {
if (val > maxVal)
val = maxVal;
if (val < minVal)