diff options
author | B Stack <bgstack15@gmail.com> | 2018-11-15 11:22:00 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-11-15 11:22:00 +0000 |
commit | 77c5c2503d459288720a8894349ac74e5eeec7c6 (patch) | |
tree | 30bf08d782d58174a0ca212b2e4b172fabd9c42c /zen/legacy_compiler.h | |
parent | Merge branch '10.5' into 'master' (diff) | |
parent | 10.6 (diff) | |
download | FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.tar.gz FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.tar.bz2 FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.zip |
Merge branch '10.6' into 'master'10.6
10.6
See merge request opensource-tracking/FreeFileSync!3
Diffstat (limited to 'zen/legacy_compiler.h')
-rwxr-xr-x | zen/legacy_compiler.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/zen/legacy_compiler.h b/zen/legacy_compiler.h index 16d87c53..bebf5a05 100755 --- a/zen/legacy_compiler.h +++ b/zen/legacy_compiler.h @@ -7,11 +7,47 @@ #ifndef LEGACY_COMPILER_H_839567308565656789 #define LEGACY_COMPILER_H_839567308565656789 +//#include <span> //requires C++20 + + namespace std { //https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html //https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations + + +//requires C++20! until then, this should suffice... +template <class T> +class span +{ +public: + template <class Iterator> + span(Iterator first, Iterator last) : size_(last - first), data_(first != last ? &*first : nullptr) {} + + template <class Container> + span(Container& cont) : span(cont.begin(), cont.end()) {} + + using iterator = T*; + using const_iterator = const T*; + + iterator begin() { return data_; } + iterator end () { return data_ + size_; } + + const_iterator begin() const { return data_; } + const_iterator end () const { return data_ + size_; } + + const_iterator cbegin() const { return begin(); } + const_iterator cend () const { return end (); } + + T* data() const { return data_; } + size_t size() const { return size_; } + bool empty() const { return size_ == 0; } + +private: + const size_t size_; + T* const data_; +}; } #endif //LEGACY_COMPILER_H_839567308565656789 |