Changeset 1340
- Timestamp:
- 05/06/25 23:06:50 (2 days ago)
- Location:
- cpp/common
- Files:
-
- 2 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 -
cpp/common/util-stl.h
r1288 r1340 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 3Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2025 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 26 26 if (it != v.end()) 27 27 v.erase(it); 28 } 29 30 // c++17 implementation of c++20 std::vector::erase_if() 31 template<typename T,typename P> void erase_if(vector<T>& v, P predicate) 32 { 33 v.erase(std::remove_if(v.begin(), v.end(), predicate), v.end()); 28 34 } 29 35
Note: See TracChangeset
for help on using the changeset viewer.