1 // Scintilla source code edit control
3 ** Safe string copy function which always NUL terminates.
4 ** ELEMENTS macro for determining array sizes.
6 // Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
7 // The License.txt file describes the conditions under which this software may be distributed.
14 // Safer version of string copy functions like strcpy, wcsncpy, etc.
15 // Instantiate over fixed length strings of both char and wchar_t.
16 // May truncate if source doesn't fit into dest with room for NUL.
18 template <typename T
, size_t count
>
19 void StringCopy(T (&dest
)[count
], const T
* source
) {
20 for (size_t i
=0; i
<count
; i
++) {
28 #define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))