diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index b80d5ebe20a..51b92d098d2 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -41,7 +41,6 @@ project "utils" MAME_DIR .. "src/lib/util/chdcd.h", MAME_DIR .. "src/lib/util/chdcodec.cpp", MAME_DIR .. "src/lib/util/chdcodec.h", - MAME_DIR .. "src/lib/util/contiguous_sequence_wrapper.h", MAME_DIR .. "src/lib/util/corealloc.h", MAME_DIR .. "src/lib/util/corefile.cpp", MAME_DIR .. "src/lib/util/corefile.h", diff --git a/src/lib/util/contiguous_sequence_wrapper.h b/src/lib/util/contiguous_sequence_wrapper.h deleted file mode 100644 index d911c4de27b..00000000000 --- a/src/lib/util/contiguous_sequence_wrapper.h +++ /dev/null @@ -1,89 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods -/****************************************************************************** - - contiguous_sequence_wrapper.h - - STL container that points to an existing contiguous sequence - -***************************************************************************/ - -#pragma once - -#ifndef MAME_LIB_UTIL_CONTIGUOUS_SEQUENCE_WRAPPER_H -#define MAME_LIB_UTIL_CONTIGUOUS_SEQUENCE_WRAPPER_H - -#include - -namespace util { - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -template -class contiguous_sequence_wrapper -{ -public: - typedef std::ptrdiff_t difference_type; - typedef std::size_t size_type; - typedef T value_type; - typedef T &reference; - typedef const T &const_reference; - typedef T *pointer; - typedef T *iterator; - typedef const T *const_iterator; - - contiguous_sequence_wrapper(T *ptr, std::size_t size) - : m_begin(ptr) - , m_end(ptr + size) - { - } - - contiguous_sequence_wrapper(const contiguous_sequence_wrapper &that) = default; - - // iteration - iterator begin() { return m_begin; } - const_iterator begin() const { return m_begin; } - const_iterator cbegin() const { return m_begin; } - iterator end() { return m_end; } - const_iterator end() const { return m_end; } - const_iterator cend() const { return m_end; } - - // reverse iteration - std::reverse_iterator rbegin() { return std::reverse_iterator(end() - 1); } - std::reverse_iterator rbegin() const { return std::reverse_iterator(end() - 1); } - std::reverse_iterator crbegin() const { return std::reverse_iterator(cend() - 1); } - std::reverse_iterator rend() { return std::reverse_iterator(begin() - 1); } - std::reverse_iterator rend() const { return std::reverse_iterator(begin() - 1); } - std::reverse_iterator crend() const { return std::reverse_iterator(begin() - 1); } - - // capacity - size_type size() const { return m_end - m_begin; } - size_type max_size() const { return size(); } - bool empty() const { return size() > 0; } - - // element access - reference front() { return operator[](0); } - const_reference front() const { return operator[](0); } - reference back() { return operator[](size() - 1); } - const_reference back() const { return operator[](size() - 1); } - reference operator[] (size_type n) { return m_begin[n]; } - const_reference operator[] (size_type n) const { return m_begin[n]; } - reference at(size_type n) { check_in_bounds(n); return operator[](n); } - const_reference at(size_type n) const { check_in_bounds(n); return operator[](n); } - -private: - iterator m_begin; - iterator m_end; - - void check_in_bounds(size_type n) - { - if (n < 0 || n >= size()) - throw new std::out_of_range("invalid contiguous_sequence_wrapper subscript"); - } -}; - -}; // namespace util - -#endif // MAME_LIB_UTIL_CONTIGUOUS_SEQUENCE_WRAPPER_H diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index b0e283378ed..fc88afeab69 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -351,4 +351,74 @@ private: }; +// ======================> contiguous_sequence_wrapper + +namespace util { + +// wraps an existing sequence of values +template +class contiguous_sequence_wrapper +{ +public: + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef T value_type; + typedef T &reference; + typedef const T &const_reference; + typedef T *pointer; + typedef T *iterator; + typedef const T *const_iterator; + + contiguous_sequence_wrapper(T *ptr, std::size_t size) + : m_begin(ptr) + , m_end(ptr + size) + { + } + + contiguous_sequence_wrapper(const contiguous_sequence_wrapper &that) = default; + + // iteration + iterator begin() { return m_begin; } + const_iterator begin() const { return m_begin; } + const_iterator cbegin() const { return m_begin; } + iterator end() { return m_end; } + const_iterator end() const { return m_end; } + const_iterator cend() const { return m_end; } + + // reverse iteration + std::reverse_iterator rbegin() { return std::reverse_iterator(end()); } + std::reverse_iterator rbegin() const { return std::reverse_iterator(end()); } + std::reverse_iterator crbegin() const { return std::reverse_iterator(cend()); } + std::reverse_iterator rend() { return std::reverse_iterator(begin()); } + std::reverse_iterator rend() const { return std::reverse_iterator(begin()); } + std::reverse_iterator crend() const { return std::reverse_iterator(begin()); } + + // capacity + size_type size() const { return m_end - m_begin; } + size_type max_size() const { return size(); } + bool empty() const { return size() > 0; } + + // element access + reference front() { return operator[](0); } + const_reference front() const { return operator[](0); } + reference back() { return operator[](size() - 1); } + const_reference back() const { return operator[](size() - 1); } + reference operator[] (size_type n) { return m_begin[n]; } + const_reference operator[] (size_type n) const { return m_begin[n]; } + reference at(size_type n) { check_in_bounds(n); return operator[](n); } + const_reference at(size_type n) const { check_in_bounds(n); return operator[](n); } + +private: + iterator m_begin; + iterator m_end; + + void check_in_bounds(size_type n) + { + if (n < 0 || n >= size()) + throw new std::out_of_range("invalid contiguous_sequence_wrapper subscript"); + } +}; + +}; // namespace util + #endif diff --git a/src/lib/util/opresolv.h b/src/lib/util/opresolv.h index 76c1f296736..760e6a237e8 100644 --- a/src/lib/util/opresolv.h +++ b/src/lib/util/opresolv.h @@ -45,7 +45,7 @@ #include #include -#include "contiguous_sequence_wrapper.h" +#include "coretmpl.h" //**************************************************************************