slibc
|
Contains overloaded templates for some _s-functions defined in string.h. More...
#include "./string.h"
Go to the source code of this file.
Functions | |
template<rsize_t s1max> | |
errno_t | strcpy_s (char(&s1)[s1max], const char *restrict s2) |
The strcpy_s template function copies the string s2 to s1. | |
template<rsize_t s1max> | |
errno_t | strncpy_s (char(&s1)[s1max], const char *restrict s2, rsize_t n) |
The strncpy_s template function copies the string s2 to s1. | |
template<rsize_t s1max> | |
errno_t | strcat_s (char(&s1)[s1max], const char *restrict s2) |
The strcat_s template function copies the string s2 to the end of s1. | |
template<rsize_t s1max> | |
errno_t | strncat_s (char(&s1)[s1max], const char *restrict s2, rsize_t n) |
The strncat_s template function copies not more than n characters of the string s2 to the end of s1. |
Contains overloaded templates for some _s-functions defined in string.h.
The usage of these templates is restricted to C++. this file is included automatically, if the macro _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES is defined. It's not necessary to declare the size of the destination buffer, when the overloaded functions are available (only if the compiler can calculate the size automatically).
The overloaded templates make the _s-functions easier to use. Buffer sizes, which are declared in the _s-functions, are already known at compilation time. This can be used by C++ templates.
Usage Example:
char buf[10]; char *input = "123456789ABCDEF"; // ContstraintHandler is called, because the input // contains more than 10 characters strcpy_s(buf, input)
As you can see it's not necessary to explicitly declare the size-parameter (usually one has to write strcpy_s(buf, sizeof(buf), input)). This feature enhances the useability (less to write) and the migration process to the new _s-functions.
errno_t strcat_s | ( | char(&) | s1[s1max], |
const char *restrict | s2 | ||
) |
The strcat_s template function copies the string s2 to the end of s1.
For statically allocated destination buffers this C++ template function automatically deducts strcat_s' size argument s1max.
[in,out] | s1 | The destination buffer |
[in] | s2 | The source string |
References strcat_s().
errno_t strcpy_s | ( | char(&) | s1[s1max], |
const char *restrict | s2 | ||
) |
The strcpy_s template function copies the string s2 to s1.
For statically allocated destination buffers this C++ template function automatically deducts strcpy_s' size argument s1max.
[out] | s1 | The destination buffer |
[in] | s2 | The source string |
References strcpy_s().
errno_t strncat_s | ( | char(&) | s1[s1max], |
const char *restrict | s2, | ||
rsize_t | n | ||
) |
The strncat_s template function copies not more than n characters of the string s2 to the end of s1.
For statically allocated destination buffers this C++ template function automatically deducts strncat_s' size argument s1max.
[in,out] | s1 | The destination buffer |
[in] | s2 | The source string |
[in] | n | Maximum amount of characters that should be copied. (If s2 is shorter than n, less bytes are copied) |
References strncat_s().
errno_t strncpy_s | ( | char(&) | s1[s1max], |
const char *restrict | s2, | ||
rsize_t | n | ||
) |
The strncpy_s template function copies the string s2 to s1.
For statically allocated destination buffers this C++ template function automatically deducts strncpy_s' size argument s1max.
[out] | s1 | The destination buffer |
[in] | s2 | The source string |
[in] | n | Maximum amount of characters that should be copied. (If s2 is shorter than n, less bytes are copied) |
References strncpy_s().