Changeset 1340 for cpp/common/nonstd_span.h
- Timestamp:
- 05/06/25 23:06:50 (2 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_span.h
r1183 r1340 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 2019-202 2Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 2019-2024 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 5 5 #ifndef _NONSTD_SPAN_H_ 6 6 #define _NONSTD_SPAN_H_ 7 8 #include <string> 9 #include <vector> 7 10 8 11 // Remove this and use std::span when available (c++20) … … 44 47 }; 45 48 49 inline std::string stringFromSpan(const span<uint8_t>& s) { return std::string(s.begin(), s.end()); } 50 inline std::string stringFromSpan(const span<char>& s) { return std::string(s.begin(), s.end()); } 51 // in both lines below, in the last argument, &*v.end() was replaced by front+size, because the debugging+extensive checking version of the STL library with std::vector complained when calling &*v.end(). 52 inline span<uint8_t> spanFromVector(std::vector<uint8_t>& v) { return span<uint8_t>(&v.front(), ((uint8_t*)&v.front())+v.size()); } 53 inline span<uint8_t> spanFromVector(std::vector<char>& v) { return span<uint8_t>((uint8_t*)&v.front(), ((uint8_t*)&v.front())+v.size()); } 54 46 55 #endif
Note: See TracChangeset
for help on using the changeset viewer.