Changeset c439e6a in mainline
- Timestamp:
- 2018-07-05T21:41:21Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5d235bf0
- Parents:
- 86d1939
- git-author:
- Dzejrou <dzejrou@…> (2018-04-24 22:49:23)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/string.hpp
r86d1939 rc439e6a 1909 1909 */ 1910 1910 1911 // TODO: implement 1911 template<class> 1912 struct hash; 1913 1914 template<> 1915 struct hash<string> 1916 { 1917 size_t operator()(const string& str) const noexcept 1918 { 1919 size_t res{}; 1920 1921 /** 1922 * Note: No need for fancy algorithms here, 1923 * std::hash is used for indexing, not 1924 * cryptography. 1925 */ 1926 for (const auto& c: str) 1927 res = res * 5 + (res >> 3) + static_cast<size_t>(c); 1928 1929 return res; 1930 } 1931 1932 using argument_type = string; 1933 using result_type = size_t; 1934 }; 1935 1936 template<> 1937 struct hash<wstring> 1938 { 1939 size_t operator()(const wstring& str) const noexcept 1940 { 1941 // TODO: implement 1942 return size_t{}; 1943 } 1944 1945 using argument_type = wstring; 1946 using result_type = size_t; 1947 }; 1948 1949 // TODO: add those other 2 string types 1912 1950 1913 1951 /** … … 1924 1962 #pragma GCC diagnostic push 1925 1963 #pragma GCC diagnostic ignored "-Wliteral-suffix" 1964 inline namespace literals { 1965 inline namespace string_literals 1966 { 1926 1967 string operator "" s(const char* str, size_t len); 1927 1968 u16string operator "" s(const char16_t* str, size_t len); … … 1931 1972 wstring operator "" s(const wchar_t* str, size_t len); 1932 1973 */ 1974 }} 1933 1975 #pragma GCC diagnostic pop 1934 1976 }
Note:
See TracChangeset
for help on using the changeset viewer.