bsnes-libretro/nall/range.hpp
Tim Allen 0955295475 Update to v098r08 release.
byuu says:

Changelog:
- nall/vector rewritten from scratch
- higan/audio uses nall/vector instead of raw pointers
- higan/sfc/coprocessor/sdd1 updated with new research information
- ruby/video/glx and ruby/video/glx2: fuck salt glXSwapIntervalEXT!

The big change here is definitely nall/vector. The Windows, OS X and Qt
ports won't compile until you change some first/last strings to
left/right, but GTK will compile.

I'd be really grateful if anyone could stress-test nall/vector. Pretty
much everything I do relies on this class. If we introduce a bug, the
worst case scenario is my entire SFC game dump database gets corrupted,
or the byuu.org server gets compromised. So it's really critical that we
test the hell out of this right now.

The S-DD1 changes mean you need to update your installation of icarus
again. Also, even though the Lunar FMV never really worked on the
accuracy core anyway (it didn't initialize the PPU properly), it really
won't work now that we emulate the hard-limit of 16MiB for S-DD1 games.
2016-05-02 19:57:04 +10:00

43 lines
978 B
C++

#pragma once
namespace nall {
struct range_t {
struct iterator {
iterator(int position, int step = 0) : position(position), step(step) {}
auto operator*() const -> int { return position; }
auto operator!=(const iterator& source) const -> bool { return step > 0 ? position < source.position : position > source.position; }
auto operator++() -> iterator& { position += step; return *this; }
private:
int position;
const int step;
};
auto begin() const -> const iterator { return iterator(origin, stride); }
auto end() const -> const iterator { return iterator(target); }
int origin;
int target;
int stride;
};
inline auto range(int size) {
return range_t{0, size, 1};
}
inline auto range(int offset, int size) {
return range_t{offset, size, 1};
}
inline auto range(int offset, int size, int step) {
return range_t{offset, size, step};
}
//reverse-range
inline auto rrange(int size) {
return range_t{size - 1, -1, -1};
}
}