Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <cstring> |
| 11 | |
| 12 | #include <cstring> |
| 13 | #include <type_traits> |
| 14 | |
| 15 | #ifndef NULL |
| 16 | #error NULL not defined |
| 17 | #endif |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | std::size_t s = 0; |
| 22 | void* vp = 0; |
| 23 | const void* vpc = 0; |
| 24 | char* cp = 0; |
| 25 | const char* cpc = 0; |
| 26 | static_assert((std::is_same<decltype(std::memcpy(vp, vpc, s)), void*>::value), ""); |
| 27 | static_assert((std::is_same<decltype(std::memmove(vp, vpc, s)), void*>::value), ""); |
| 28 | static_assert((std::is_same<decltype(std::strcpy(cp, cpc)), char*>::value), ""); |
| 29 | static_assert((std::is_same<decltype(std::strncpy(cp, cpc, s)), char*>::value), ""); |
| 30 | static_assert((std::is_same<decltype(std::strcat(cp, cpc)), char*>::value), ""); |
| 31 | static_assert((std::is_same<decltype(std::strncat(cp, cpc, s)), char*>::value), ""); |
| 32 | static_assert((std::is_same<decltype(std::memcmp(vpc, vpc, s)), int>::value), ""); |
| 33 | static_assert((std::is_same<decltype(std::strcmp(cpc, cpc)), int>::value), ""); |
| 34 | static_assert((std::is_same<decltype(std::strncmp(cpc, cpc, s)), int>::value), ""); |
| 35 | static_assert((std::is_same<decltype(std::strcoll(cpc, cpc)), int>::value), ""); |
| 36 | static_assert((std::is_same<decltype(std::strxfrm(cp, cpc, s)), std::size_t>::value), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 37 | // static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)), const void*>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 38 | static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 39 | // static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 40 | static_assert((std::is_same<decltype(std::strchr(cp, 0)), char*>::value), ""); |
| 41 | static_assert((std::is_same<decltype(std::strcspn(cpc, cpc)), std::size_t>::value), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 42 | // static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)), const char*>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 43 | static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 44 | // static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const char*>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | static_assert((std::is_same<decltype(std::strrchr(cp, 0)), char*>::value), ""); |
| 46 | static_assert((std::is_same<decltype(std::strspn(cpc, cpc)), std::size_t>::value), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 47 | // static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const char*>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 48 | static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), ""); |
Ed Schouten | 323ade3 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 49 | #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 50 | static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), ""); |
Ed Schouten | 323ade3 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 51 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 52 | static_assert((std::is_same<decltype(std::memset(vp, 0, s)), void*>::value), ""); |
| 53 | static_assert((std::is_same<decltype(std::strerror(0)), char*>::value), ""); |
| 54 | static_assert((std::is_same<decltype(std::strlen(cpc)), std::size_t>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | } |