mirror of
https://github.com/zeldaret/st
synced 2026-06-29 11:20:58 -04:00
Decompile overlay 1 (Part 2) (#91)
* UnkStruct_027e09b8_001 OK * match func_ov001_020b7830 * fix build issues * UnkStruct_027e0cd8_001 49% * UnkStruct_027e0cd8_001 OK * fix build issues * UnkStruct_027e0cd8_0C_001 92% * port some MSL C++ headers from rb3 and key decomps * fix build issues * UnkStruct_027e0cd8_0C_001 98%
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#ifndef _STD_ALGORITHM_H
|
||||
#define _STD_ALGORITHM_H
|
||||
|
||||
// from rb3/key decomp
|
||||
|
||||
#include <msl_unk.hpp>
|
||||
|
||||
namespace std {
|
||||
|
||||
template <class T> inline const T &min(const T &a, const T &b) {
|
||||
return b < a ? b : a;
|
||||
}
|
||||
|
||||
template <class T> inline const T &max(const T &a, const T &b) {
|
||||
return a < b ? b : a;
|
||||
}
|
||||
|
||||
template <class T, class _Compare> inline const T &min(const T &a, const T &b, _Compare comp) {
|
||||
return comp(b, a) ? b : a;
|
||||
}
|
||||
|
||||
template <class T, class _Compare> inline const T &max(const T &a, const T &b, _Compare comp) {
|
||||
return comp(a, b) ? b : a;
|
||||
}
|
||||
|
||||
template <typename InputIterator, typename Predicate>
|
||||
inline InputIterator find_if(InputIterator first, InputIterator last, Predicate p) {
|
||||
for (; first != last && !p(*first); ++first) {
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
template <typename It, typename T> inline It find(It first, It last, const T &value) {
|
||||
while (first != last && *first != value) {
|
||||
first++;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
// adapted from https://github.com/matta/sgi-stl/blob/635eaeef4533214ec140fb17411558ad441d2996/stl/stl_algo.h#L638
|
||||
template <typename It, typename T> inline It remove(It first, It last, const T &value) {
|
||||
first = find(first, last, value);
|
||||
|
||||
if (first != last) {
|
||||
It it = first;
|
||||
|
||||
for (it++; it != last; it++) {
|
||||
if (*it != value) {
|
||||
*first = *it;
|
||||
first++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
template <typename T, typename Size, bool V /* ? */> struct __fill_n {
|
||||
static inline void fill_n(T *first, Size n, const T &value) {
|
||||
for (; n != 0; first++, n--) {
|
||||
*first = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename OutputIt /* ? */, typename Size, typename T>
|
||||
inline void fill_n(OutputIt *first, Size n, const T &value) {
|
||||
__fill_n<OutputIt, Size, false>::fill_n(first, n, value);
|
||||
}
|
||||
|
||||
template <typename T> inline T &move(T &p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
template <typename T> inline void swap(T &a, T &b) {
|
||||
T temp = move(a);
|
||||
a = move(b);
|
||||
b = move(temp);
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,156 @@
|
||||
#ifndef _STD_PAIR
|
||||
#define _STD_PAIR
|
||||
|
||||
// from key decomp
|
||||
|
||||
#include "type_traits.hpp"
|
||||
|
||||
namespace Metrowerks {
|
||||
|
||||
namespace details {
|
||||
|
||||
template <typename T1, typename T2, bool T1Empty = std::is_empty<T1>::value, bool T2Empty = std::is_empty<T2>::value>
|
||||
struct compressed_pair_selector {
|
||||
static const int value = 0;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> struct compressed_pair_selector<T1, T2, true, false> {
|
||||
static const int value = 1;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> struct compressed_pair_selector<T1, T2, false, true> {
|
||||
static const int value = 2;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> struct compressed_pair_selector<T1, T2, true, true> {
|
||||
static const int value = 3;
|
||||
};
|
||||
|
||||
template <typename T> struct compressed_pair_selector<T, T, false, false> {
|
||||
static const int value = 0;
|
||||
};
|
||||
|
||||
template <typename T> struct compressed_pair_selector<T, T, true, true> {
|
||||
static const int value = 1;
|
||||
};
|
||||
|
||||
// Note to future self: template signature must stay as-is for symbols
|
||||
template <typename T1, typename T2, int Selector = compressed_pair_selector<T1, T2>::value> class compressed_pair_imp {
|
||||
public:
|
||||
typedef typename Metrowerks::call_traits<T1>::param_type first_param;
|
||||
typedef typename Metrowerks::call_traits<T2>::param_type second_param;
|
||||
|
||||
compressed_pair_imp() {}
|
||||
compressed_pair_imp(first_param first, second_param second) :
|
||||
m_First(first),
|
||||
m_Second(second) {}
|
||||
compressed_pair_imp(first_param first) :
|
||||
m_First(first) {}
|
||||
compressed_pair_imp(second_param second) :
|
||||
m_Second(second) {}
|
||||
|
||||
T1 &first() {
|
||||
return m_First;
|
||||
}
|
||||
const T1 &first() const {
|
||||
return m_First;
|
||||
}
|
||||
|
||||
T2 &second() {
|
||||
return m_Second;
|
||||
}
|
||||
const T2 &second() const {
|
||||
return m_Second;
|
||||
}
|
||||
|
||||
private:
|
||||
T1 m_First;
|
||||
T2 m_Second;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> class compressed_pair_imp<T1, T2, 1> : private T1 {
|
||||
public:
|
||||
typedef typename Metrowerks::call_traits<T1>::param_type first_param;
|
||||
typedef typename Metrowerks::call_traits<T2>::param_type second_param;
|
||||
|
||||
compressed_pair_imp() {}
|
||||
compressed_pair_imp(first_param first, second_param second) :
|
||||
T1(first),
|
||||
m_Second(second) {}
|
||||
compressed_pair_imp(first_param first) :
|
||||
T1(first) {}
|
||||
compressed_pair_imp(second_param second) :
|
||||
m_Second(second) {}
|
||||
|
||||
T1 &first() {
|
||||
return *this;
|
||||
}
|
||||
const T1 &first() const {
|
||||
return *this;
|
||||
}
|
||||
|
||||
T2 &second() {
|
||||
return m_Second;
|
||||
}
|
||||
const T2 &second() const {
|
||||
return m_Second;
|
||||
}
|
||||
|
||||
private:
|
||||
T2 m_Second;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> class compressed_pair_imp<T1, T2, 2> : private T2 {
|
||||
public:
|
||||
typedef typename Metrowerks::call_traits<T1>::param_type first_param;
|
||||
typedef typename Metrowerks::call_traits<T2>::param_type second_param;
|
||||
|
||||
compressed_pair_imp() {}
|
||||
compressed_pair_imp(first_param first, second_param second) :
|
||||
m_First(first),
|
||||
T2(second) {}
|
||||
compressed_pair_imp(first_param first) :
|
||||
m_First(first) {}
|
||||
compressed_pair_imp(second_param second) :
|
||||
T2(second) {}
|
||||
|
||||
T1 &first() {
|
||||
return m_First;
|
||||
}
|
||||
const T1 &first() const {
|
||||
return m_First;
|
||||
}
|
||||
|
||||
T2 &second() {
|
||||
return *this;
|
||||
}
|
||||
const T2 &second() const {
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
T1 m_First;
|
||||
};
|
||||
} // namespace details
|
||||
|
||||
template <typename T1, typename T2> struct compressed_pair : public details::compressed_pair_imp<T1, T2> {
|
||||
typedef typename details::compressed_pair_imp<T1, T2>::first_param first_param;
|
||||
typedef typename details::compressed_pair_imp<T1, T2>::second_param second_param;
|
||||
typedef details::compressed_pair_imp<T1, T2> _Base;
|
||||
|
||||
compressed_pair() {}
|
||||
compressed_pair(first_param first) :
|
||||
_Base(first) {}
|
||||
compressed_pair(second_param second) :
|
||||
_Base(second) {}
|
||||
compressed_pair(first_param first, second_param second) :
|
||||
_Base(first, second) {}
|
||||
|
||||
template <class U, class V>
|
||||
compressed_pair(const compressed_pair<U, V> &p) :
|
||||
_Base(p.first(), p.second()) {}
|
||||
};
|
||||
|
||||
} // namespace Metrowerks
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _STD_CSTDDEF_H
|
||||
#define _STD_CSTDDEF_H
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace std {
|
||||
using ::ptrdiff_t;
|
||||
using ::size_t;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef _STD_CSTRING_H
|
||||
#define _STD_CSTRING_H
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <string.h>
|
||||
#include <mem.h>
|
||||
|
||||
namespace std {
|
||||
using ::size_t;
|
||||
|
||||
using ::memchr;
|
||||
using ::memcmp;
|
||||
using ::memcpy;
|
||||
using ::memmove;
|
||||
using ::memset;
|
||||
|
||||
// using ::strcat;
|
||||
using ::strcpy;
|
||||
// using ::strncat;
|
||||
using ::strncpy;
|
||||
// using ::strxfrm;
|
||||
|
||||
// using ::strchr;
|
||||
using ::strcmp;
|
||||
// using ::strcoll;
|
||||
// using ::strcspn;
|
||||
using ::strlen;
|
||||
using ::strncmp;
|
||||
// using ::strpbrk;
|
||||
// using ::strrchr;
|
||||
// using ::strspn;
|
||||
// using ::strstr;
|
||||
// using ::strtok;
|
||||
|
||||
// using ::strerror;
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,82 @@
|
||||
#ifndef MSL_CPP_CWCHAR_H
|
||||
#define MSL_CPP_CWCHAR_H
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <wstring.h>
|
||||
|
||||
namespace std {
|
||||
// using ::mbstate_t;
|
||||
// using ::wint_t;
|
||||
using ::size_t;
|
||||
// using ::tm;
|
||||
|
||||
// using ::wcscat;
|
||||
using ::wcscpy;
|
||||
// using ::wcsncat;
|
||||
using ::wcsncpy;
|
||||
// using ::wcsxfrm;
|
||||
|
||||
using ::wcschr;
|
||||
// using ::wcscmp;
|
||||
// using ::wcscoll;
|
||||
// using ::wcscspn;
|
||||
using ::wcslen;
|
||||
// using ::wcsncmp;
|
||||
// using ::wcspbrk;
|
||||
// using ::wcsrchr;
|
||||
// using ::wcsspn;
|
||||
// using ::wcsstr;
|
||||
// using ::wcstok;
|
||||
|
||||
// using ::wmemchr;
|
||||
// using ::wmemcmp;
|
||||
// using ::wmemcpy;
|
||||
// using ::wmemmove;
|
||||
// using ::wmemset;
|
||||
|
||||
// using ::btowc;
|
||||
// using ::mbrlen;
|
||||
// using ::mbrtowc;
|
||||
// using ::mbsinit;
|
||||
// using ::mbsrtowcs;
|
||||
// using ::wcrtomb;
|
||||
// using ::wcsrtombs;
|
||||
// using ::wctob;
|
||||
|
||||
// using ::fgetwc;
|
||||
// using ::fgetws;
|
||||
// using ::fputwc;
|
||||
// using ::fputws;
|
||||
// using ::getwc;
|
||||
// using ::getwchar;
|
||||
// using ::putwc;
|
||||
// using ::putwchar;
|
||||
// using ::ungetwc;
|
||||
|
||||
// using ::fwide;
|
||||
|
||||
// using ::fwprintf;
|
||||
// using ::fwscanf;
|
||||
// using ::swprintf;
|
||||
// using ::swscanf;
|
||||
// using ::vfwprintf;
|
||||
// using ::vfwscanf;
|
||||
// using ::vswprintf;
|
||||
// using ::vswscanf;
|
||||
// using ::vwprintf;
|
||||
// using ::vwscanf;
|
||||
// using ::wprintf;
|
||||
// using ::wscanf;
|
||||
|
||||
// using ::wcsftime;
|
||||
// using ::wcstod;
|
||||
// using ::wcstof;
|
||||
// using ::wcstol;
|
||||
// using ::wcstold;
|
||||
// using ::wcstoll;
|
||||
// using ::wcstoul;
|
||||
// using ::wcstoull;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef _STD_DEFAULT_DELETE
|
||||
#define _STD_DEFAULT_DELETE
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <new>
|
||||
|
||||
namespace std {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T> struct default_delete {
|
||||
void operator()(T *ptr) {
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct default_delete<T[]> {
|
||||
void operator()(T ptr[]) {
|
||||
delete[] ptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef _STD_EXCEPTION
|
||||
#define _STD_EXCEPTION
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
namespace std {
|
||||
|
||||
class exception {
|
||||
public:
|
||||
exception() {}
|
||||
virtual ~exception() {}
|
||||
virtual const char *what() const {
|
||||
return "exception";
|
||||
}
|
||||
};
|
||||
|
||||
class bad_exception : public exception {
|
||||
public:
|
||||
bad_exception() {}
|
||||
virtual ~bad_exception() {}
|
||||
virtual const char *what() const {
|
||||
return "bad_exception";
|
||||
}
|
||||
};
|
||||
|
||||
typedef void (*unexpected_handler)();
|
||||
unexpected_handler set_unexpected(unexpected_handler f) throw();
|
||||
void unexpected();
|
||||
|
||||
typedef void (*terminate_handler)();
|
||||
terminate_handler set_terminate(terminate_handler f) throw();
|
||||
void terminate();
|
||||
|
||||
bool uncaught_exception() throw();
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
#ifndef _STD_IOSFWD
|
||||
#define _STD_IOSFWD
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <cwchar>
|
||||
|
||||
namespace std {
|
||||
|
||||
typedef mbstate_t __char_state_type;
|
||||
typedef mbstate_t __wchar_state_type;
|
||||
|
||||
template <class CharT>
|
||||
struct char_traits;
|
||||
template <>
|
||||
struct char_traits<char>;
|
||||
template <>
|
||||
struct char_traits<wchar_t>;
|
||||
|
||||
template <class T>
|
||||
class allocator;
|
||||
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_ios;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_streambuf;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_istream;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_ostream;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_iostream;
|
||||
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_filebuf;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_ifstream;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_ofstream;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class basic_fstream;
|
||||
|
||||
template <
|
||||
class CharT,
|
||||
class Traits = char_traits<CharT>,
|
||||
class Allocator = allocator<CharT> >
|
||||
class basic_stringbuf;
|
||||
template <
|
||||
class CharT,
|
||||
class Traits = char_traits<CharT>,
|
||||
class Allocator = allocator<CharT> >
|
||||
class basic_istringstream;
|
||||
template <
|
||||
class CharT,
|
||||
class Traits = char_traits<CharT>,
|
||||
class Allocator = allocator<CharT> >
|
||||
class basic_ostringstream;
|
||||
template <
|
||||
class CharT,
|
||||
class Traits = char_traits<CharT>,
|
||||
class Allocator = allocator<CharT> >
|
||||
class basic_stringstream;
|
||||
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class istreambuf_iterator;
|
||||
template <class CharT, class Traits = char_traits<CharT> >
|
||||
class ostreambuf_iterator;
|
||||
|
||||
typedef basic_ios<char> ios;
|
||||
typedef basic_ios<wchar_t> wios;
|
||||
|
||||
typedef basic_streambuf<char> streambuf;
|
||||
typedef basic_istream<char> istream;
|
||||
typedef basic_ostream<char> ostream;
|
||||
typedef basic_iostream<char> iostream;
|
||||
|
||||
typedef basic_stringbuf<char> stringbuf;
|
||||
typedef basic_istringstream<char> istringstream;
|
||||
typedef basic_ostringstream<char> ostringstream;
|
||||
typedef basic_stringstream<char> stringstream;
|
||||
|
||||
typedef basic_filebuf<char> filebuf;
|
||||
typedef basic_ifstream<char> ifstream;
|
||||
typedef basic_ofstream<char> ofstream;
|
||||
typedef basic_fstream<char> fstream;
|
||||
|
||||
typedef basic_streambuf<wchar_t> wstreambuf;
|
||||
typedef basic_istream<wchar_t> wistream;
|
||||
typedef basic_ostream<wchar_t> wostream;
|
||||
typedef basic_iostream<wchar_t> wiostream;
|
||||
|
||||
typedef basic_stringbuf<wchar_t> wstringbuf;
|
||||
typedef basic_istringstream<wchar_t> wistringstream;
|
||||
typedef basic_ostringstream<wchar_t> wostringstream;
|
||||
typedef basic_stringstream<wchar_t> wstringstream;
|
||||
|
||||
typedef basic_filebuf<wchar_t> wfilebuf;
|
||||
typedef basic_ifstream<wchar_t> wifstream;
|
||||
typedef basic_ofstream<wchar_t> wofstream;
|
||||
typedef basic_fstream<wchar_t> wfstream;
|
||||
|
||||
template <class State>
|
||||
class fpos;
|
||||
|
||||
typedef fpos<__char_state_type /*char_traits<char>::state_type*/> streampos;
|
||||
typedef fpos<__wchar_state_type /*char_traits<wchar_t>::state_type*/> wstreampos;
|
||||
|
||||
class strstreambuf;
|
||||
class istrstream;
|
||||
class ostrstream;
|
||||
class strstream;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,371 @@
|
||||
#ifndef _STD_ITERATOR_H
|
||||
#define _STD_ITERATOR_H
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
// clang-format off: too excessive with splitting things into multiple lines
|
||||
|
||||
// Based on https://github.com/SwareJonge/mkdd/blob/main/libs/PowerPC_EABI_Support/include/iterator
|
||||
|
||||
#include <cstddef>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace std {
|
||||
|
||||
struct input_iterator_tag {};
|
||||
struct output_iterator_tag {};
|
||||
struct forward_iterator_tag : public input_iterator_tag {};
|
||||
struct bidirectional_iterator_tag : public forward_iterator_tag {};
|
||||
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct iterator_traits {
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
template <typename IteratorTag, typename ValueType, typename DifferenceType = ptrdiff_t,
|
||||
typename Pointer = ValueType *, typename Reference = ValueType &>
|
||||
struct iterator {
|
||||
typedef IteratorTag iterator_category;
|
||||
typedef ValueType value_type;
|
||||
typedef DifferenceType difference_type;
|
||||
typedef Pointer pointer;
|
||||
typedef Reference reference;
|
||||
};
|
||||
|
||||
template <class Container>
|
||||
class insert_iterator : public iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef iterator<output_iterator_tag, void, void, void, void> _Base;
|
||||
|
||||
public:
|
||||
typedef Container container_type;
|
||||
|
||||
typedef typename _Base::iterator_category iterator_category;
|
||||
typedef typename _Base::value_type value_type;
|
||||
typedef typename _Base::difference_type difference_type;
|
||||
typedef typename _Base::pointer pointer;
|
||||
typedef typename _Base::reference reference;
|
||||
|
||||
insert_iterator() {}
|
||||
insert_iterator(Container& c, typename Container::iterator i)
|
||||
: container(&c), iter(i) { }
|
||||
|
||||
insert_iterator& operator=(typename Container::const_reference value) {
|
||||
iter = container->insert(iter, value);
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
insert_iterator& operator*() { return *this; }
|
||||
insert_iterator& operator++() { return *this; }
|
||||
insert_iterator& operator++(int) { return *this; }
|
||||
|
||||
protected:
|
||||
Container* container;
|
||||
typename Container::iterator iter;
|
||||
};
|
||||
|
||||
template <class Container>
|
||||
insert_iterator<Container> inserter(Container& c, typename Container::iterator i) {
|
||||
return insert_iterator<Container>(c, i);
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
class front_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef iterator<output_iterator_tag, void, void, void, void> _Base;
|
||||
|
||||
public:
|
||||
typedef Container container_type;
|
||||
|
||||
typedef typename _Base::iterator_category iterator_category;
|
||||
typedef typename _Base::value_type value_type;
|
||||
typedef typename _Base::difference_type difference_type;
|
||||
typedef typename _Base::pointer pointer;
|
||||
typedef typename _Base::reference reference;
|
||||
|
||||
explicit front_insert_iterator(Container& c) : container(&c) { }
|
||||
|
||||
front_insert_iterator& operator=(typename Container::const_reference value) {
|
||||
typename Container::iterator iter = container->push_front(iter, value);
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
front_insert_iterator& operator*() { return *this; }
|
||||
front_insert_iterator& operator++() { return *this; }
|
||||
front_insert_iterator& operator++(int) { return *this; }
|
||||
|
||||
protected:
|
||||
Container* container;
|
||||
};
|
||||
|
||||
template <class Container>
|
||||
front_insert_iterator<Container> front_inserter(Container& c) {
|
||||
return front_insert_iterator<Container>(c);
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
class back_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef iterator<output_iterator_tag, void, void, void, void> _Base;
|
||||
|
||||
public:
|
||||
typedef Container container_type;
|
||||
|
||||
typedef typename _Base::iterator_category iterator_category;
|
||||
typedef typename _Base::value_type value_type;
|
||||
typedef typename _Base::difference_type difference_type;
|
||||
typedef typename _Base::pointer pointer;
|
||||
typedef typename _Base::reference reference;
|
||||
|
||||
explicit back_insert_iterator(Container& c) : container(&c) { }
|
||||
|
||||
back_insert_iterator& operator=(typename Container::const_reference value) {
|
||||
typename Container::iterator iter = container->push_back(iter, value);
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
back_insert_iterator& operator*() { return *this; }
|
||||
back_insert_iterator& operator++() { return *this; }
|
||||
back_insert_iterator& operator++(int) { return *this; }
|
||||
|
||||
protected:
|
||||
Container* container;
|
||||
};
|
||||
|
||||
template <class Container>
|
||||
back_insert_iterator<Container> back_inserter(Container& c) {
|
||||
return back_insert_iterator<Container>(c);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
class reverse_iterator : public iterator<
|
||||
typename iterator_traits<Iter>::iterator_category,
|
||||
typename iterator_traits<Iter>::value_type,
|
||||
typename iterator_traits<Iter>::difference_type,
|
||||
typename iterator_traits<Iter>::pointer,
|
||||
typename iterator_traits<Iter>::reference
|
||||
> {
|
||||
typedef iterator<
|
||||
typename iterator_traits<Iter>::iterator_category,
|
||||
typename iterator_traits<Iter>::value_type,
|
||||
typename iterator_traits<Iter>::difference_type,
|
||||
typename iterator_traits<Iter>::pointer,
|
||||
typename iterator_traits<Iter>::reference
|
||||
> _Base;
|
||||
|
||||
public:
|
||||
typedef Iter iterator_type;
|
||||
|
||||
typedef typename _Base::iterator_category iterator_category;
|
||||
typedef typename _Base::value_type value_type;
|
||||
typedef typename _Base::difference_type difference_type;
|
||||
typedef typename _Base::pointer pointer;
|
||||
typedef typename _Base::reference reference;
|
||||
|
||||
reverse_iterator() {}
|
||||
explicit reverse_iterator(Iter itr) : current(itr) {}
|
||||
|
||||
template <typename U>
|
||||
reverse_iterator(const reverse_iterator<U>& other) : current(other.current) {}
|
||||
|
||||
template <typename U>
|
||||
reverse_iterator& operator=(const reverse_iterator<U>& other) {
|
||||
current = other.current;
|
||||
}
|
||||
|
||||
Iter base() { return current; }
|
||||
|
||||
reference operator*() const {
|
||||
Iter it = current;
|
||||
--it;
|
||||
return *it;
|
||||
}
|
||||
|
||||
pointer operator->() const {
|
||||
return &(operator*());
|
||||
}
|
||||
|
||||
reverse_iterator& operator++() {
|
||||
--current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reverse_iterator operator++(int) {
|
||||
reverse_iterator tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
reverse_iterator& operator--() {
|
||||
++current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reverse_iterator operator--(int) {
|
||||
reverse_iterator tmp = *this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
reverse_iterator operator+(difference_type n) const {
|
||||
return reverse_iterator(current - n);
|
||||
}
|
||||
|
||||
reverse_iterator& operator+=(difference_type n) {
|
||||
current -= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reverse_iterator operator-(difference_type n) const {
|
||||
return reverse_iterator(current + n);
|
||||
}
|
||||
|
||||
reverse_iterator& operator-=(difference_type n) {
|
||||
current += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator[](difference_type n) const {
|
||||
return current[-n - 1];
|
||||
}
|
||||
|
||||
protected:
|
||||
Iter current;
|
||||
};
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator==(const reverse_iterator<Iterator1> &lhs, const reverse_iterator<Iterator2> &rhs) {
|
||||
return lhs.base() == rhs.base();
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator<(const reverse_iterator<Iterator1> &lhs, const reverse_iterator<Iterator2> &rhs) {
|
||||
return lhs.base() < rhs.base();
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator!=(const reverse_iterator<Iterator1> &lhs, const reverse_iterator<Iterator2> &rhs) {
|
||||
return !(lhs.base() == rhs.base());
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator>(const reverse_iterator<Iterator1> &lhs, const reverse_iterator<Iterator2> &rhs) {
|
||||
return rhs.base() < lhs.base();
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator<=(const reverse_iterator<Iterator1> &lhs, const reverse_iterator<Iterator2> &rhs) {
|
||||
return !(rhs.base() < lhs.base());
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator>=(const reverse_iterator<Iterator1> &lhs, const reverse_iterator<Iterator2> &rhs) {
|
||||
return !(lhs.base() < rhs.base());
|
||||
}
|
||||
|
||||
template<class Iter>
|
||||
reverse_iterator<Iter> operator+(
|
||||
typename reverse_iterator<Iter>::difference_type lhs,
|
||||
const reverse_iterator<Iter>& rhs
|
||||
) {
|
||||
return rhs + lhs;
|
||||
}
|
||||
|
||||
template<class Iter1, class Iter2>
|
||||
typename reverse_iterator<Iter1>::difference_type operator-(
|
||||
const reverse_iterator<Iter1>& lhs,
|
||||
const reverse_iterator<Iter2>& rhs
|
||||
) {
|
||||
return rhs.base() - lhs.base();
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
reverse_iterator<Iter> make_reverse_iterator(Iter itr) {
|
||||
return reverse_iterator<Iter>(itr);
|
||||
}
|
||||
|
||||
template <class T, class CharT = char, class Traits = char_traits<CharT>, class Distance = ptrdiff_t>
|
||||
class istream_iterator : public iterator<input_iterator_tag, T, Distance, const T *, const T &> {};
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator==(const istream_iterator<Iterator1> &lhs, const istream_iterator<Iterator2> &rhs);
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator!=(const istream_iterator<Iterator1> &lhs, const istream_iterator<Iterator2> &rhs);
|
||||
|
||||
template <class T, class CharT = char, class Traits = char_traits<CharT> >
|
||||
class ostream_iterator : public iterator<output_iterator_tag, void, void, void, void> {};
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator==(const ostream_iterator<Iterator1> &lhs, const ostream_iterator<Iterator2> &rhs);
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator!=(const ostream_iterator<Iterator1> &lhs, const ostream_iterator<Iterator2> &rhs);
|
||||
|
||||
template <class CharT, class Traits /*= char_traits<CharT>*/ >
|
||||
class istreambuf_iterator : public iterator<input_iterator_tag, CharT, typename Traits::off_type, CharT *, CharT> {};
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator==(const istreambuf_iterator<Iterator1> &lhs, const istreambuf_iterator<Iterator2> &rhs);
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator!=(const istreambuf_iterator<Iterator1> &lhs, const istreambuf_iterator<Iterator2> &rhs);
|
||||
|
||||
template <class CharT, class Traits /*= char_traits<CharT>*/ >
|
||||
class ostreambuf_iterator : public iterator<output_iterator_tag, void, void, void, void> {};
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator==(const ostreambuf_iterator<Iterator1> &lhs, const ostreambuf_iterator<Iterator2> &rhs);
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool operator!=(const ostreambuf_iterator<Iterator1> &lhs, const ostreambuf_iterator<Iterator2> &rhs);
|
||||
|
||||
template <class Iterator, class Distance>
|
||||
void __advance(Iterator &it, Distance n, input_iterator_tag) {
|
||||
for (; n > 0; --n)
|
||||
++it;
|
||||
}
|
||||
|
||||
template <class Iterator, class Distance>
|
||||
void __advance(Iterator &it, Distance n, bidirectional_iterator_tag) {
|
||||
// positive value
|
||||
for (; n > 0; --n)
|
||||
++it;
|
||||
|
||||
// negative value
|
||||
for (; n < 0; ++n)
|
||||
--it;
|
||||
}
|
||||
|
||||
template <class Iterator, class Distance>
|
||||
void __advance(Iterator &it, Distance n, random_access_iterator_tag) {
|
||||
it += n;
|
||||
}
|
||||
|
||||
template <class Iterator, class Distance>
|
||||
void advance(Iterator &it, Distance n) {
|
||||
return __advance(it, n, iterator_traits<Iterator>::iterator_category());
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
typename iterator_traits<Iterator>::difference_type
|
||||
__distance(Iterator first, Iterator last, input_iterator_tag) {
|
||||
typename iterator_traits<Iterator>::difference_type result = 0;
|
||||
for (; first != last; ++first)
|
||||
++result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
typename iterator_traits<Iterator>::difference_type
|
||||
__distance(Iterator first, Iterator last, random_access_iterator_tag) {
|
||||
return last - first;
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
typename iterator_traits<Iterator>::difference_type
|
||||
distance(Iterator first, Iterator last) {
|
||||
return __distance(first, last, iterator_traits<Iterator>::iterator_category());
|
||||
}
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,131 @@
|
||||
#ifndef _STD_LIMITS_H
|
||||
#define _STD_LIMITS_H
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
// Based on https://github.com/SwareJonge/mkdd/blob/main/libs/PowerPC_EABI_Support/include/limits
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
class numeric_limits {
|
||||
public:
|
||||
static T min();
|
||||
static T max();
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<bool> {
|
||||
public:
|
||||
static bool min() { return false; }
|
||||
static bool max() { return true; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<char> {
|
||||
public:
|
||||
static char min() { return -0x80; }
|
||||
static char max() { return 0x7F; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<signed char> {
|
||||
public:
|
||||
static signed char min() { return -0x80; }
|
||||
static signed char max() { return 0x7F; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<unsigned char> {
|
||||
public:
|
||||
static unsigned char min() { return 0x0; }
|
||||
static unsigned char max() { return 0xFF; }
|
||||
};
|
||||
|
||||
// template <>
|
||||
// class numeric_limits<short> {
|
||||
// public:
|
||||
// static short min() { return -0x8000; }
|
||||
// static short max() { return 0x7FFF; }
|
||||
// };
|
||||
|
||||
template <>
|
||||
class numeric_limits<signed short> {
|
||||
public:
|
||||
static signed short min() { return -0x8000; }
|
||||
static signed short max() { return 0x7FFF; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<unsigned short> {
|
||||
public:
|
||||
static unsigned short min() { return 0x0; }
|
||||
static unsigned short max() { return 0xFFFF; }
|
||||
};
|
||||
|
||||
// template <>
|
||||
// class numeric_limits<int> {
|
||||
// public:
|
||||
// static int min() { return -0x80000000; }
|
||||
// static int max() { return 0x7FFFFFFF; }
|
||||
// };
|
||||
|
||||
template <>
|
||||
class numeric_limits<signed int> {
|
||||
public:
|
||||
static signed int min() { return -0x80000000; }
|
||||
static signed int max() { return 0x7FFFFFFF; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<unsigned int> {
|
||||
public:
|
||||
static unsigned int min() { return 0x0; }
|
||||
static unsigned int max() { return 0xFFFFFFFF; }
|
||||
};
|
||||
|
||||
// template <>
|
||||
// class numeric_limits<long> {
|
||||
// public:
|
||||
// static long min() { return -0x80000000; }
|
||||
// static long max() { return 0x7FFFFFFF; }
|
||||
// };
|
||||
|
||||
template <>
|
||||
class numeric_limits<signed long> {
|
||||
public:
|
||||
static signed long min() { return -0x80000000; }
|
||||
static signed long max() { return 0x7FFFFFFF; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<unsigned long> {
|
||||
public:
|
||||
static unsigned long min() { return 0x0; }
|
||||
static unsigned long max() { return 0xFFFFFFFF; }
|
||||
};
|
||||
|
||||
// template <>
|
||||
// class numeric_limits<long long> {
|
||||
// public:
|
||||
// static long long min() { return -0x8000000000000000; }
|
||||
// static long long max() { return 0x7FFFFFFFFFFFFFFF; }
|
||||
// };
|
||||
|
||||
template <>
|
||||
class numeric_limits<signed long long> {
|
||||
public:
|
||||
static signed long long min() { return -0x8000000000000000; }
|
||||
static signed long long max() { return 0x7FFFFFFFFFFFFFFF; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class numeric_limits<unsigned long long> {
|
||||
public:
|
||||
static unsigned long long min() { return 0x0; }
|
||||
static unsigned long long max() { return 0xFFFFFFFFFFFFFFFF; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef _STD_MEMORY
|
||||
#define _STD_MEMORY
|
||||
|
||||
#include <new>
|
||||
#include <limits>
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
namespace std {
|
||||
template <class T> class allocator {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef T &reference;
|
||||
typedef const T &const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
|
||||
template <class U> struct rebind {
|
||||
typedef allocator<U> other;
|
||||
};
|
||||
|
||||
allocator() {}
|
||||
allocator(const allocator<T> &) {}
|
||||
template <class U> allocator(const allocator<U> &) {}
|
||||
~allocator() {}
|
||||
|
||||
size_type max_size() const throw() {
|
||||
return std::numeric_limits<size_t>::max() / sizeof(T);
|
||||
}
|
||||
|
||||
pointer allocate(size_type count, const void *hint = 0) {
|
||||
return reinterpret_cast<pointer>(::operator new(count * sizeof(T), 1, 4));
|
||||
}
|
||||
|
||||
void deallocate(pointer p, size_type n) {
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
void construct(pointer p, const_reference val) {
|
||||
new(p) T(val);
|
||||
}
|
||||
|
||||
void destroy(pointer p) {
|
||||
p->~T();
|
||||
}
|
||||
};
|
||||
}; // namespace std
|
||||
|
||||
#endif // _STD_MEMORY
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
struct UnkMSLStruct1 {};
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef _STD_NEW
|
||||
#define _STD_NEW
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
void *operator new(size_t size);
|
||||
void *operator new[](size_t size);
|
||||
void operator delete(void *ptr);
|
||||
void operator delete[](void *ptr);
|
||||
|
||||
inline void *operator new(size_t length, void *ptr) {
|
||||
#pragma unused(length)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline void *operator new[](size_t length, void *ptr) {
|
||||
#pragma unused(length)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline void operator delete(void *ptr, void *place) {}
|
||||
|
||||
inline void operator delete[](void *ptr, void *place) {}
|
||||
|
||||
#endif // _STD_NEW
|
||||
@@ -0,0 +1,109 @@
|
||||
#ifndef _STD_SHARED_PTR
|
||||
#define _STD_SHARED_PTR
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <cstddef>
|
||||
#include <typeinfo>
|
||||
|
||||
#include "compressed_pair.hpp"
|
||||
|
||||
#include "default_delete.hpp"
|
||||
|
||||
// clang-format off
|
||||
namespace std {
|
||||
|
||||
namespace tr1 {
|
||||
namespace detail {
|
||||
|
||||
class shared_ptr_deleter_common {
|
||||
public:
|
||||
virtual ~shared_ptr_deleter_common() {}
|
||||
// Return type is most definitely not correct
|
||||
virtual const void *get_deleter(const std::type_info &info) const = 0;
|
||||
|
||||
protected:
|
||||
virtual void dispose() = 0;
|
||||
|
||||
public:
|
||||
void release();
|
||||
|
||||
int m_RefCount;
|
||||
int m_WeakCount;
|
||||
};
|
||||
|
||||
template <typename T, typename Deleter = std::detail::default_delete<T> >
|
||||
class shared_ptr_deleter : public shared_ptr_deleter_common {
|
||||
public:
|
||||
shared_ptr_deleter(T *ptr) :
|
||||
m_Ptr(ptr) {}
|
||||
~shared_ptr_deleter() {}
|
||||
|
||||
const void *get_deleter(const std::type_info &info) const {
|
||||
if (info == typeid(Deleter)) {
|
||||
return &m_Ptr.second();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
void dispose() {
|
||||
m_Ptr.second()(m_Ptr.first());
|
||||
}
|
||||
|
||||
private:
|
||||
Metrowerks::compressed_pair<T *, Deleter> m_Ptr;
|
||||
};
|
||||
|
||||
template <typename T> class shared_ptr_base {
|
||||
protected:
|
||||
void __set(T *ptr, tr1::detail::shared_ptr_deleter_common *deleter) {
|
||||
m_Ptr = ptr;
|
||||
m_Deleter = deleter;
|
||||
}
|
||||
|
||||
public:
|
||||
~shared_ptr_base() throw() {
|
||||
if (m_Deleter) {
|
||||
m_Deleter->release();
|
||||
}
|
||||
}
|
||||
|
||||
T *get() const {
|
||||
return m_Ptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
T *m_Ptr;
|
||||
tr1::detail::shared_ptr_deleter_common *m_Deleter;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace tr1
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T> class shared_ptr : public tr1::detail::shared_ptr_base<T> {
|
||||
public:
|
||||
shared_ptr();
|
||||
|
||||
explicit shared_ptr(T *ptr) {
|
||||
__set(ptr, new tr1::detail::shared_ptr_deleter<T>(ptr));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> class shared_ptr<T[]> : public tr1::detail::shared_ptr_base<T> {
|
||||
public:
|
||||
shared_ptr();
|
||||
|
||||
explicit shared_ptr(T ptr[]) {
|
||||
this->__set(ptr, new tr1::detail::shared_ptr_deleter<T, std::detail::default_delete<T[]> >(ptr));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace std
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef _STD_STDEXCEPT
|
||||
#define _STD_STDEXCEPT
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include "shared_ptr.hpp"
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
namespace std {
|
||||
|
||||
class logic_error : public exception {
|
||||
public:
|
||||
explicit logic_error(const char *what_arg) :
|
||||
m_What(new char[strlen(what_arg) + 1]) {}
|
||||
|
||||
virtual const char *what() const {
|
||||
return (char *)m_What.get();
|
||||
}
|
||||
|
||||
private:
|
||||
detail::shared_ptr<char[]> m_What;
|
||||
};
|
||||
|
||||
class runtime_error : public exception {
|
||||
public:
|
||||
explicit runtime_error(const char *what_arg) :
|
||||
m_What(new char[strlen(what_arg) + 1]) {}
|
||||
|
||||
virtual const char *what() const {
|
||||
return m_What.get();
|
||||
}
|
||||
|
||||
private:
|
||||
detail::shared_ptr<char[]> m_What;
|
||||
};
|
||||
|
||||
class domain_error : public logic_error {
|
||||
public:
|
||||
explicit domain_error(const char *what_arg) :
|
||||
logic_error(what_arg) {}
|
||||
};
|
||||
|
||||
class invalid_argument : public logic_error {
|
||||
public:
|
||||
explicit invalid_argument(const char *what_arg) :
|
||||
logic_error(what_arg) {}
|
||||
};
|
||||
|
||||
class length_error : public logic_error {
|
||||
public:
|
||||
explicit length_error(const char *what_arg) :
|
||||
logic_error(what_arg) {}
|
||||
};
|
||||
|
||||
class out_of_range : public logic_error {
|
||||
public:
|
||||
explicit out_of_range(const char *what_arg) :
|
||||
logic_error(what_arg) {}
|
||||
};
|
||||
|
||||
class range_error : public runtime_error {
|
||||
public:
|
||||
explicit range_error(const char *what_arg) :
|
||||
runtime_error(what_arg) {}
|
||||
};
|
||||
|
||||
class overflow_error : public runtime_error {
|
||||
public:
|
||||
explicit overflow_error(const char *what_arg) :
|
||||
runtime_error(what_arg) {}
|
||||
};
|
||||
|
||||
class underflow_error : public runtime_error {
|
||||
public:
|
||||
explicit underflow_error(const char *what_arg) :
|
||||
runtime_error(what_arg) {}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef _STD_TYPE_TRAITS
|
||||
#define _STD_TYPE_TRAITS
|
||||
|
||||
// from rb3 decomp
|
||||
//! TODO: these files aren't supposed to be organised like this according to rb3/key decomps
|
||||
|
||||
// Anachronistic backport of a large amount of the template metaprogramming library.
|
||||
// Most implementation details are copied straight from cppreference,
|
||||
// with others being copied from Boost, and a few using MSL intrinsics.
|
||||
|
||||
#include "type_traits/category.hpp"
|
||||
#include "type_traits/integral_constant.hpp"
|
||||
#include "type_traits/manip.hpp"
|
||||
#include "type_traits/manip_2.hpp"
|
||||
#include "type_traits/operation.hpp"
|
||||
#include "type_traits/property.hpp"
|
||||
#include "type_traits/relationship.hpp"
|
||||
#include "type_traits/utility.hpp"
|
||||
|
||||
#include "type_traits/call_traits.hpp"
|
||||
#include "type_traits/intrinsics.hpp"
|
||||
|
||||
namespace Metrowerks {
|
||||
template <int I> struct int2type {
|
||||
enum {
|
||||
val = I
|
||||
};
|
||||
|
||||
// static const int value = I;
|
||||
|
||||
// int value; // assumed
|
||||
};
|
||||
} // namespace Metrowerks
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,122 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
template <typename T> struct is_function : public false_type {};
|
||||
|
||||
template <typename Ret> struct is_function<Ret (*)()> : public true_type {};
|
||||
|
||||
template <typename Ret> struct is_function<Ret (*)(...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1> struct is_function<Ret (*)(T1)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1> struct is_function<Ret (*)(T1, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2> struct is_function<Ret (*)(T1, T2)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2> struct is_function<Ret (*)(T1, T2, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3> struct is_function<Ret (*)(T1, T2, T3)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3>
|
||||
struct is_function<Ret (*)(T1, T2, T3, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13, typename T14>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13, typename T14>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ...)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)> : public true_type {};
|
||||
|
||||
template <typename Ret, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16>
|
||||
struct is_function<Ret (*)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ...)> : public true_type {};
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef _METROWERKS_TYPE_TRAITS_CALL_TRAITS
|
||||
#define _METROWERKS_TYPE_TRAITS_CALL_TRAITS
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
namespace Metrowerks {
|
||||
|
||||
namespace details {
|
||||
|
||||
// probably doesn't cover all useful cases (e.g. long long),
|
||||
// but this will do for our purposes
|
||||
|
||||
template <typename T, bool Small = sizeof(T) <= sizeof(void *)> struct call_traits_imp {
|
||||
typedef const T param_type;
|
||||
};
|
||||
|
||||
template <typename T> struct call_traits_imp<T, false> {
|
||||
typedef const T ¶m_type;
|
||||
};
|
||||
|
||||
template <typename T, bool Small> struct call_traits_imp<T *, Small> {
|
||||
typedef T *param_type;
|
||||
};
|
||||
|
||||
template <typename T, bool Small> struct call_traits_imp<const T *, Small> {
|
||||
typedef const T *param_type;
|
||||
};
|
||||
|
||||
template <typename T, bool Small> struct call_traits_imp<T &, Small> {
|
||||
typedef T ¶m_type;
|
||||
};
|
||||
|
||||
template <typename T, bool Small> struct call_traits_imp<const T &, Small> {
|
||||
typedef const T ¶m_type;
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
|
||||
// name known; boost
|
||||
template <typename T> struct call_traits {
|
||||
typedef T value_type;
|
||||
typedef T &reference;
|
||||
typedef const T &const_reference;
|
||||
typedef typename details::call_traits_imp<T>::param_type param_type;
|
||||
};
|
||||
|
||||
} // namespace Metrowerks
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_CATEGORY
|
||||
#define _MSL_TYPE_TRAITS_CATEGORY
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "type_traits/call_traits.hpp"
|
||||
#include "type_traits/intrinsics.hpp"
|
||||
|
||||
#include "type_traits/integral_constant.hpp"
|
||||
#include "type_traits/manip.hpp"
|
||||
#include "type_traits/operation.hpp"
|
||||
#include "type_traits/relationship.hpp"
|
||||
|
||||
// clang-format off: conciseness
|
||||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
struct is_void : public is_same<typename remove_cv<T>::type, void> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_integral : public bool_constant<Metrowerks::is_integral<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_floating_point : public bool_constant<Metrowerks::is_floating_point<T>::value> {};
|
||||
|
||||
template <typename T> struct is_array : public false_type {};
|
||||
template <typename T> struct is_array<T[]> : public true_type {};
|
||||
template <typename T, std::size_t N> struct is_array<T[N]> : public true_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_enum : public bool_constant<Metrowerks::is_enum<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_union : public bool_constant<Metrowerks::is_union<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_class : public bool_constant<Metrowerks::is_class<T>::value> {};
|
||||
|
||||
// C++11: needs variadic template args to implement properly
|
||||
// As a stopgap, variants for up to 16 parameters are generated
|
||||
#include "_category_function.hpp"
|
||||
|
||||
template <typename T> struct is_pointer : public false_type {};
|
||||
template <typename T> struct is_pointer<T*> : public true_type {};
|
||||
template <typename T> struct is_pointer<T* const> : public true_type {};
|
||||
template <typename T> struct is_pointer<T* volatile> : public true_type {};
|
||||
template <typename T> struct is_pointer<T* const volatile> : public true_type {};
|
||||
|
||||
template <typename T> struct is_lvalue_reference : public false_type {};
|
||||
template <typename T> struct is_lvalue_reference<T&> : public true_type {};
|
||||
|
||||
template <typename T> struct is_rvalue_reference : public false_type {};
|
||||
// template <typename T> struct is_rvalue_reference<T&&> : public true_type {}; // C++11
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct is_member_pointer : public false_type {};
|
||||
|
||||
template <typename T, typename U>
|
||||
struct is_member_pointer<T U::*> : public true_type {};
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_member_pointer
|
||||
: public detail::is_member_pointer<typename remove_cv<T>::type> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_member_object_pointer : public bool_constant<
|
||||
is_member_pointer<T>::value &&
|
||||
!is_function<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_member_function_pointer : public bool_constant<
|
||||
is_member_pointer<T>::value &&
|
||||
is_function<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_arithmetic : public bool_constant<
|
||||
is_integral<T>::value ||
|
||||
is_floating_point<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_fundamental : public bool_constant<
|
||||
is_arithmetic<T>::value ||
|
||||
is_void<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_scalar : public bool_constant<
|
||||
is_arithmetic<T>::value ||
|
||||
is_enum<T>::value ||
|
||||
is_pointer<T>::value ||
|
||||
is_member_pointer<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_object : public bool_constant<
|
||||
is_scalar<T>::value ||
|
||||
is_array<T>::value ||
|
||||
is_union<T>::value ||
|
||||
is_class<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_compound : public negation<is_fundamental<T> > {};
|
||||
|
||||
template <typename T>
|
||||
struct is_reference : public bool_constant<
|
||||
is_lvalue_reference<T>::value ||
|
||||
is_rvalue_reference<T>::value
|
||||
> {};
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_INTEGRAL_CONSTANT
|
||||
#define _MSL_TYPE_TRAITS_INTEGRAL_CONSTANT
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename T, T V> struct integral_constant {
|
||||
static const T value = V;
|
||||
|
||||
typedef T value_type;
|
||||
typedef integral_constant type;
|
||||
|
||||
operator const value_type() const throw() {
|
||||
return value;
|
||||
}
|
||||
const value_type operator()() const throw() {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
|
||||
template <bool B> struct bool_constant : public integral_constant<bool, B> {};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,258 @@
|
||||
#ifndef _METROWERKS_TYPE_TRAITS_INTRINSICS
|
||||
#define _METROWERKS_TYPE_TRAITS_INTRINSICS
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
// Builtins reference: https://decomp.me/scratch/k4ZpJ
|
||||
|
||||
namespace Metrowerks {
|
||||
|
||||
namespace detail {
|
||||
|
||||
#ifdef DECOMP_IDE_FLAG
|
||||
#define __builtin_ntype(T) (detail::ntype) 0
|
||||
#define __builtin_align(T) 0
|
||||
#define __builtin_is_pod(T) 0
|
||||
#define __builtin_is_polymorphic(T) 0
|
||||
#define __builtin_is_abstract(T) 0
|
||||
#define __builtin_trivial_members(T) 0
|
||||
#define __builtin_trivial_members(T) 0
|
||||
#define __builtin_trivial_members(T) 0
|
||||
#define __builtin_trivial_members(T) 0
|
||||
#define __builtin_trivial_members(T) 0
|
||||
#define __builtin_has_nothrow_default_constructor(T) 0
|
||||
#define __builtin_has_nothrow_copy(T) 0
|
||||
#define __builtin_has_nothrow_assign(T) 0
|
||||
#define __builtin_has_nothrow_destructor(T) 0
|
||||
#define __builtin_has_virtual_destructor(T) 0
|
||||
typedef double short_double;
|
||||
typedef double __vec2x32float__;
|
||||
#else
|
||||
typedef short double short_double;
|
||||
#endif
|
||||
|
||||
enum trivial_member {
|
||||
trivial_dtor = 0x01,
|
||||
trivial_copy_assign = 0x02,
|
||||
trivial_copy_ctor = 0x04,
|
||||
trivial_default_ctor = 0x08,
|
||||
};
|
||||
|
||||
enum ntype {
|
||||
ntype_void = 0x00,
|
||||
|
||||
ntype_bool = 0x01,
|
||||
|
||||
ntype_char = 0x02,
|
||||
ntype_signed_char = 0x03,
|
||||
ntype_unsigned_char = 0x04,
|
||||
|
||||
ntype_wchar_t = 0x05,
|
||||
|
||||
ntype_signed_short = 0x06,
|
||||
ntype_unsigned_short = 0x07,
|
||||
|
||||
ntype_signed_int = 0x08,
|
||||
ntype_unsigned_int = 0x09,
|
||||
|
||||
ntype_signed_long = 0x0A,
|
||||
ntype_unsigned_long = 0x0B, // assumed, the actual result is the same as
|
||||
// ntype_signed_long for some reason
|
||||
|
||||
ntype_signed_long_long = 0x0C,
|
||||
ntype_unsigned_long_long = 0x0D,
|
||||
|
||||
ntype_float = 0x0E,
|
||||
ntype_short_double = 0x0F,
|
||||
ntype_double = 0x10,
|
||||
ntype_long_double = 0x11,
|
||||
|
||||
ntype_vec2x32float = 0x22,
|
||||
|
||||
ntype_type_mask = 0xFF,
|
||||
|
||||
ntype_flag_integral = 0x0100,
|
||||
ntype_flag_floating = 0x0200,
|
||||
ntype_flag_enum = 0x0400,
|
||||
|
||||
ntype_pointer = 0x0800,
|
||||
ntype_array = 0x1000,
|
||||
|
||||
ntype_class = 0x2000,
|
||||
ntype_union = 0x2001,
|
||||
ntype_pointer_to_member = 0x4000,
|
||||
|
||||
ntype_function = 0x8000,
|
||||
|
||||
ntype_flag_0x10000 = 0x10000,
|
||||
};
|
||||
|
||||
// clang-format off: conciseness
|
||||
template <ntype N>
|
||||
struct ntype_to_integral_helper;
|
||||
|
||||
template <> struct ntype_to_integral_helper<ntype_void> { typedef void type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_bool> { typedef bool type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_char> { typedef char type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_signed_char> { typedef signed char type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_unsigned_char> { typedef unsigned char type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_wchar_t> { typedef wchar_t type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_signed_short> { typedef signed short type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_unsigned_short> { typedef unsigned short type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_signed_int> { typedef signed int type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_unsigned_int> { typedef unsigned int type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_signed_long> { typedef signed long type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_unsigned_long> { typedef unsigned long type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_signed_long_long> { typedef signed long long type; };
|
||||
template <> struct ntype_to_integral_helper<ntype_unsigned_long_long> { typedef unsigned long long type; };
|
||||
|
||||
template <ntype N>
|
||||
struct ntype_to_integral : public ntype_to_integral_helper<ntype(N & ntype_type_mask)> {};
|
||||
|
||||
template <ntype N>
|
||||
struct ntype_to_floating_helper;
|
||||
|
||||
template <> struct ntype_to_floating_helper<ntype_float> { typedef float type; };
|
||||
template <> struct ntype_to_floating_helper<ntype_short_double> { typedef short_double type; };
|
||||
template <> struct ntype_to_floating_helper<ntype_double> { typedef double type; };
|
||||
template <> struct ntype_to_floating_helper<ntype_long_double> { typedef long double type; };
|
||||
// template <> struct ntype_to_floating_helper<ntype_vec2x32float> { typedef __vec2x32float__ type; };
|
||||
|
||||
template <ntype N>
|
||||
struct ntype_to_floating : public ntype_to_floating_helper<ntype(N & ntype_type_mask)> {};
|
||||
|
||||
template <ntype N, bool integer, bool floating>
|
||||
struct ntype_to_type_helper;
|
||||
|
||||
template <ntype N>
|
||||
struct ntype_to_type_helper<N, true, false> : public ntype_to_integral<N> {};
|
||||
|
||||
template <ntype N>
|
||||
struct ntype_to_type_helper<N, false, true> : public ntype_to_floating<N> {};
|
||||
|
||||
template <ntype N>
|
||||
struct ntype_to_type : public ntype_to_type_helper<
|
||||
ntype(N & ntype_type_mask),
|
||||
bool(N & ntype_flag_integral),
|
||||
bool(N & ntype_flag_floating)
|
||||
> {};
|
||||
|
||||
// __builtin_ntype doesn't respect ref types correctly
|
||||
template <typename T, ntype NType>
|
||||
struct ntype_ref_helper {
|
||||
static const bool value = __builtin_ntype(T) == NType;
|
||||
};
|
||||
|
||||
template <typename T, ntype NType>
|
||||
struct ntype_ref_helper<T&, NType> {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <typename T, ntype Flag>
|
||||
struct ntype_ref_helper_flag {
|
||||
static const bool value = (__builtin_ntype(T) & Flag) == Flag;
|
||||
};
|
||||
|
||||
template <typename T, ntype Flag>
|
||||
struct ntype_ref_helper_flag<T&, Flag> {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T> struct alignment_of {
|
||||
static const std::size_t value = __builtin_align(T);
|
||||
};
|
||||
|
||||
template <typename T> struct is_integral {
|
||||
static const bool value = detail::ntype_ref_helper_flag<T, detail::ntype_flag_integral>::value;
|
||||
};
|
||||
|
||||
template <typename T> struct is_floating_point {
|
||||
static const bool value = detail::ntype_ref_helper_flag<T, detail::ntype_flag_floating>::value;
|
||||
};
|
||||
|
||||
template <typename T> struct is_enum {
|
||||
static const bool value = detail::ntype_ref_helper_flag<T, detail::ntype_flag_enum>::value;
|
||||
};
|
||||
|
||||
template <typename T> struct is_class {
|
||||
static const bool value = detail::ntype_ref_helper<T, detail::ntype_class>::value;
|
||||
};
|
||||
|
||||
// name known; boost
|
||||
template <typename T> struct is_union {
|
||||
static const bool value = detail::ntype_ref_helper<T, detail::ntype_union>::value;
|
||||
};
|
||||
|
||||
// name known; boost/STLport
|
||||
template <typename T> struct is_POD {
|
||||
static const bool value = __builtin_is_pod(T);
|
||||
};
|
||||
|
||||
template <typename T> struct is_polymorphic {
|
||||
static const bool value = __builtin_is_polymorphic(T);
|
||||
};
|
||||
|
||||
template <typename T> struct is_abstract {
|
||||
static const bool value = __builtin_is_abstract(T);
|
||||
};
|
||||
|
||||
template <typename T> struct is_trivial {
|
||||
static const bool value = __builtin_trivial_members(T) == (detail::trivial_dtor | detail::trivial_copy_assign |
|
||||
detail::trivial_copy_ctor | detail::trivial_default_ctor);
|
||||
};
|
||||
|
||||
// name known; boost/STLport
|
||||
template <typename T> struct has_trivial_default_ctor {
|
||||
static const bool value = __builtin_trivial_members(T) & detail::trivial_default_ctor;
|
||||
};
|
||||
|
||||
// name known; boost/STLport
|
||||
template <typename T> struct has_trivial_copy_ctor {
|
||||
static const bool value = __builtin_trivial_members(T) & detail::trivial_copy_ctor;
|
||||
};
|
||||
|
||||
// name known; boost/STLport
|
||||
template <typename T> struct has_trivial_assignment {
|
||||
static const bool value = __builtin_trivial_members(T) & detail::trivial_copy_assign;
|
||||
};
|
||||
|
||||
// name known; boost/STLport
|
||||
template <typename T> struct has_trivial_dtor {
|
||||
static const bool value = __builtin_trivial_members(T) & detail::trivial_dtor;
|
||||
};
|
||||
|
||||
template <typename T> struct has_nothrow_default_ctor {
|
||||
static const bool value = __builtin_has_nothrow_default_constructor(T);
|
||||
};
|
||||
|
||||
template <typename T> struct has_nothrow_copy_ctor {
|
||||
static const bool value = __builtin_has_nothrow_copy(T);
|
||||
};
|
||||
|
||||
template <typename T> struct has_nothrow_assignment {
|
||||
static const bool value = __builtin_has_nothrow_assign(T);
|
||||
};
|
||||
|
||||
template <typename T> struct has_nothrow_dtor {
|
||||
static const bool value = __builtin_has_nothrow_destructor(T);
|
||||
};
|
||||
|
||||
template <typename T> struct has_virtual_dtor {
|
||||
static const bool value = __builtin_has_virtual_destructor(T);
|
||||
};
|
||||
|
||||
template <typename T, bool IsEnum> struct underlying_type_helper {};
|
||||
|
||||
template <typename T> struct underlying_type_helper<T, true> : public detail::ntype_to_integral<__builtin_ntype(T)> {};
|
||||
|
||||
template <typename T> struct underlying_type : public underlying_type_helper<T, is_enum<T>::value> {};
|
||||
|
||||
} // namespace Metrowerks
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_MANIP
|
||||
#define _MSL_TYPE_TRAITS_MANIP
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "type_traits/call_traits.hpp"
|
||||
#include "type_traits/intrinsics.hpp"
|
||||
|
||||
// clang-format off: conciseness
|
||||
namespace std {
|
||||
|
||||
#pragma region "const-volatile modifications"
|
||||
template <typename T> struct add_const { typedef const T type; };
|
||||
template <typename T> struct add_volatile { typedef volatile T type; };
|
||||
template <typename T> struct add_cv { typedef const volatile T type; };
|
||||
|
||||
template <typename T> struct remove_const { typedef T type; };
|
||||
template <typename T> struct remove_const<const T> { typedef T type; };
|
||||
template <typename T> struct remove_const<const volatile T> { typedef volatile T type; };
|
||||
|
||||
template <typename T> struct remove_volatile { typedef T type; };
|
||||
template <typename T> struct remove_volatile<volatile T> { typedef T type; };
|
||||
template <typename T> struct remove_volatile<const volatile T> { typedef const T type; };
|
||||
|
||||
template <typename T> struct remove_cv { typedef T type; };
|
||||
template <typename T> struct remove_cv<const T> { typedef T type; };
|
||||
template <typename T> struct remove_cv<volatile T> { typedef T type; };
|
||||
template <typename T> struct remove_cv<const volatile T> { typedef T type; };
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename From, typename To> struct copy_const { typedef To type; };
|
||||
template <typename From, typename To> struct copy_const<const From, To> { typedef const To type; };
|
||||
|
||||
template <typename From, typename To> struct copy_volatile { typedef To type; };
|
||||
template <typename From, typename To> struct copy_volatile<volatile From, To> { typedef volatile To type; };
|
||||
|
||||
template <typename From, typename To> struct copy_cv { typedef From type; };
|
||||
template <typename From, typename To> struct copy_cv<const From, To> { typedef const To type; };
|
||||
template <typename From, typename To> struct copy_cv<volatile From, To> { typedef volatile To type; };
|
||||
template <typename From, typename To> struct copy_cv<const volatile From, To> { typedef const volatile To type; };
|
||||
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "reference modifications"
|
||||
template <typename T> struct add_lvalue_reference { typedef T& type; };
|
||||
// template <typename T> struct add_rvalue_reference { typedef T&& type; }; // C++11
|
||||
|
||||
template <> struct add_lvalue_reference<void> { typedef void type; };
|
||||
template <> struct add_lvalue_reference<const void> { typedef const void type; };
|
||||
template <> struct add_lvalue_reference<volatile void> { typedef volatile void type; };
|
||||
template <> struct add_lvalue_reference<const volatile void> { typedef const volatile void type; };
|
||||
|
||||
template <typename T> struct remove_reference { typedef T type; };
|
||||
template <typename T> struct remove_reference<T&> { typedef T type; };
|
||||
// template <typename T> struct remove_reference<T&&> { typedef T type; }; // C++11
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "pointer modifications"
|
||||
template <typename T> struct add_pointer { typedef typename remove_reference<T>::type* type; };
|
||||
|
||||
template <typename T> struct remove_pointer { typedef T type; };
|
||||
template <typename T> struct remove_pointer<T*> { typedef T type; };
|
||||
template <typename T> struct remove_pointer<T* const> { typedef T type; };
|
||||
template <typename T> struct remove_pointer<T* volatile> { typedef T type; };
|
||||
template <typename T> struct remove_pointer<T* const volatile> { typedef T type; };
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "array modifications"
|
||||
template <typename T> struct remove_extent { typedef T type; };
|
||||
template <typename T> struct remove_extent<T[]> { typedef T type; };
|
||||
template <typename T, std::size_t N> struct remove_extent<T[N]> { typedef T type; };
|
||||
|
||||
template <typename T> struct remove_all_extents { typedef T type; };
|
||||
template <typename T> struct remove_all_extents<T[]> { typedef typename remove_all_extents<T>::type type; };
|
||||
template <typename T, std::size_t N> struct remove_all_extents<T[N]> { typedef typename remove_all_extents<T>::type type; };
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "miscellaneous transformations"
|
||||
|
||||
// Not implementable, __attribute__ ((aligned (i))) doesn't work with template args
|
||||
// template <std::size_t Len, std::size_t Align = 4> struct aligned_storage;
|
||||
|
||||
// template <std::size_t Len, typename... Types> struct aligned_union
|
||||
|
||||
template <typename T>
|
||||
struct remove_cvref {
|
||||
typedef typename remove_cv<typename remove_reference<T>::value>::value type;
|
||||
};
|
||||
|
||||
// template <typename... T> struct common_type;
|
||||
|
||||
template <typename T>
|
||||
struct underlying_type {
|
||||
typedef typename Metrowerks::underlying_type<T>::value type;
|
||||
};
|
||||
|
||||
// template <typename Fn, typename... ArgTypes> struct result_of;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_MANIP_2
|
||||
#define _MSL_TYPE_TRAITS_MANIP_2
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
// Separate for manip traits that aren't free-standing
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "type_traits/category.hpp"
|
||||
#include "type_traits/manip.hpp"
|
||||
|
||||
// clang-format off: conciseness
|
||||
namespace std {
|
||||
|
||||
#pragma region "sign modifications"
|
||||
namespace detail {
|
||||
|
||||
template <typename T> struct make_signed_helper;
|
||||
|
||||
template <> struct make_signed_helper<signed char> { typedef signed char type; };
|
||||
template <> struct make_signed_helper<signed short> { typedef signed short type; };
|
||||
template <> struct make_signed_helper<signed int> { typedef signed int type; };
|
||||
template <> struct make_signed_helper<signed long> { typedef signed long type; };
|
||||
template <> struct make_signed_helper<signed long long> { typedef signed long long type; };
|
||||
|
||||
template <> struct make_signed_helper<unsigned char> { typedef signed char type; };
|
||||
template <> struct make_signed_helper<unsigned short> { typedef signed short type; };
|
||||
template <> struct make_signed_helper<unsigned int> { typedef signed int type; };
|
||||
template <> struct make_signed_helper<unsigned long> { typedef signed long type; };
|
||||
template <> struct make_signed_helper<unsigned long long> { typedef signed long long type; };
|
||||
|
||||
template <> struct make_signed_helper<char> { typedef signed char type; };
|
||||
template <> struct make_signed_helper<wchar_t> { typedef signed short type; };
|
||||
|
||||
template <typename T, bool IsEnum = is_enum<T>::value>
|
||||
struct make_signed : public make_signed_helper<T> {};
|
||||
|
||||
template <typename T>
|
||||
struct make_signed<T, true> : public make_signed_helper<typename underlying_type<T>::type> {};
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct make_signed : public detail::copy_cv<T, detail::make_signed<typename remove_cv<T>::type> > {};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T> struct make_unsigned_helper;
|
||||
|
||||
template <> struct make_unsigned_helper<signed char> { typedef unsigned char type; };
|
||||
template <> struct make_unsigned_helper<signed short> { typedef unsigned short type; };
|
||||
template <> struct make_unsigned_helper<signed int> { typedef unsigned int type; };
|
||||
template <> struct make_unsigned_helper<signed long> { typedef unsigned long type; };
|
||||
template <> struct make_unsigned_helper<signed long long> { typedef unsigned long long type; };
|
||||
|
||||
template <> struct make_unsigned_helper<unsigned char> { typedef unsigned char type; };
|
||||
template <> struct make_unsigned_helper<unsigned short> { typedef unsigned short type; };
|
||||
template <> struct make_unsigned_helper<unsigned int> { typedef unsigned int type; };
|
||||
template <> struct make_unsigned_helper<unsigned long> { typedef unsigned long type; };
|
||||
template <> struct make_unsigned_helper<unsigned long long> { typedef unsigned long long type; };
|
||||
|
||||
template <> struct make_unsigned_helper<char> { typedef unsigned char type; };
|
||||
template <> struct make_unsigned_helper<wchar_t> { typedef unsigned short type; };
|
||||
|
||||
template <typename T, bool IsEnum = is_enum<T>::value>
|
||||
struct make_unsigned : public make_unsigned_helper<T> {};
|
||||
|
||||
template <typename T>
|
||||
struct make_unsigned<T, true> : public make_unsigned_helper<typename underlying_type<T>::type> {};
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct make_unsigned : public detail::copy_cv<T, detail::make_unsigned<typename remove_cv<T>::type> > {};
|
||||
#pragma endregion
|
||||
|
||||
template<class T>
|
||||
struct decay
|
||||
{
|
||||
private:
|
||||
typedef typename remove_reference<T>::type U;
|
||||
|
||||
public:
|
||||
typedef typename conditional<
|
||||
is_array<U>::value,
|
||||
typename add_pointer<typename remove_extent<U>::type>::type,
|
||||
typename conditional<
|
||||
is_function<U>::value,
|
||||
typename add_pointer<U>::type,
|
||||
typename remove_cv<U>::type
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_OPERATION
|
||||
#define _MSL_TYPE_TRAITS_OPERATION
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include "integral_constant.hpp"
|
||||
|
||||
// clang-format off: conciseness
|
||||
namespace std {
|
||||
|
||||
#pragma region "enable_if: logical if"
|
||||
template <bool B, typename T = void>
|
||||
struct enable_if {};
|
||||
template <typename T>
|
||||
struct enable_if<true, T> { typedef T type; };
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "conditional: logical if/else"
|
||||
template <bool B, typename T, typename F> struct conditional;
|
||||
template <typename T, typename F> struct conditional<true, T, F> { typedef T type; };
|
||||
template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "conjunction: logical AND; all"
|
||||
// template <typename... B> struct conjunction;
|
||||
struct conjunction : public true_type {};
|
||||
|
||||
template <typename B1, typename B2>
|
||||
struct conjunction2 : public conditional< !bool(B1::value), B1, B2 >::type {};
|
||||
|
||||
template <typename B1, typename B2, typename B3>
|
||||
struct conjunction3 : public conditional< !bool(B1::value), B1, conjunction2<B2, B3> >::type {};
|
||||
|
||||
template <typename B1, typename B2, typename B3, typename B4>
|
||||
struct conjunction4 : public conditional< !bool(B1::value), B1, conjunction3<B2, B3, B4> >::type {};
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "disjunction: logical OR; any"
|
||||
// template <typename... B> struct disjunction;
|
||||
struct disjunction : public false_type {};
|
||||
|
||||
template <typename B1, typename B2>
|
||||
struct disjunction2 : public conditional< bool(B1::value), B1, B2>::type {};
|
||||
|
||||
template <typename B1, typename B2, typename B3>
|
||||
struct disjunction3 : public conditional< bool(B1::value), B1, disjunction2<B2, B3> >::type {};
|
||||
|
||||
template <typename B1, typename B2, typename B3, typename B4>
|
||||
struct disjunction4 : public conditional< bool(B1::value), B1, disjunction3<B2, B3, B4> >::type {};
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "negation: logical NOT"
|
||||
template <typename B>
|
||||
struct negation : public integral_constant<bool, !bool(B::value)> {};
|
||||
|
||||
// NAND; not all
|
||||
struct negative_conjunction : public negation<conjunction> {};
|
||||
template <typename B1, typename B2>
|
||||
struct negative_conjunction2 : public negation<conjunction2<B1, B2> > {};
|
||||
template <typename B1, typename B2, typename B3>
|
||||
struct negative_conjunction3 : public negation<conjunction3<B1, B2, B3> > {};
|
||||
template <typename B1, typename B2, typename B3, typename B4>
|
||||
struct negative_conjunction4 : public negation<conjunction4<B1, B2, B3, B4> > {};
|
||||
|
||||
// NOR; not any
|
||||
struct negative_disjunction : public negation<disjunction> {};
|
||||
template <typename B1, typename B2>
|
||||
struct negative_disjunction2 : public negation<disjunction2<B1, B2> > {};
|
||||
template <typename B1, typename B2, typename B3>
|
||||
struct negative_disjunction3 : public negation<disjunction3<B1, B2, B3> > {};
|
||||
template <typename B1, typename B2, typename B3, typename B4>
|
||||
struct negative_disjunction4 : public negation<disjunction4<B1, B2, B3, B4> > {};
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,150 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_PROPERTY
|
||||
#define _MSL_TYPE_TRAITS_PROPERTY
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include "type_traits/call_traits.hpp"
|
||||
#include "type_traits/intrinsics.hpp"
|
||||
|
||||
#include "type_traits/category.hpp"
|
||||
#include "type_traits/integral_constant.hpp"
|
||||
#include "type_traits/relationship.hpp"
|
||||
|
||||
// clang-format off: conciseness
|
||||
namespace std {
|
||||
|
||||
#pragma region "type properties"
|
||||
template <typename T> struct is_const : public false_type {};
|
||||
template <typename T> struct is_const<const T> : public true_type {};
|
||||
|
||||
template <typename T> struct is_volatile : public false_type {};
|
||||
template <typename T> struct is_volatile<volatile T> : public true_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_trivial : public bool_constant<Metrowerks::is_trivial<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_trivially_copyable : public bool_constant<
|
||||
Metrowerks::has_trivial_copy_ctor<T>::value &&
|
||||
Metrowerks::has_trivial_assignment<T>::value
|
||||
> {};
|
||||
|
||||
template <typename T> struct is_standard_layout;
|
||||
|
||||
template <typename T>
|
||||
struct is_pod : public bool_constant<Metrowerks::is_POD<T>::value> {};
|
||||
|
||||
template <typename T> struct is_literal_type;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct is_empty_helper1 : public T { int i; };
|
||||
struct is_empty_helper2 { int i; };
|
||||
|
||||
template <typename T, bool IsInheritable = is_class<T>::value>
|
||||
struct is_empty : public bool_constant<sizeof(is_empty_helper1<T>) == sizeof(is_empty_helper2)> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_empty<T, false> : public false_type {};
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_empty : public detail::is_empty<T> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_polymorphic : public bool_constant<Metrowerks::is_polymorphic<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_abstract : public bool_constant<Metrowerks::is_abstract<T>::value> {};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, bool IsArithmetic = is_arithmetic<T>::value>
|
||||
struct is_signed : public bool_constant<(T(0) > T(-1))> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_signed<T, false> : public false_type {};
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_signed : public detail::is_signed<T> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_unsigned : public bool_constant<!is_signed<T>::value> {};
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "supported operations"
|
||||
// template <typename T, typename... Args> struct is_constructible;
|
||||
// template <typename T, typename... Args> struct is_trivially_constructible;
|
||||
// template <typename T, typename... Args> struct is_nothrow_constructible;
|
||||
|
||||
template <typename T> struct is_default_constructible;
|
||||
template <typename T> struct is_trivially_default_constructible
|
||||
: public bool_constant<Metrowerks::has_trivial_default_ctor<T>::value> {};
|
||||
template <typename T> struct is_nothrow_default_constructible
|
||||
: public bool_constant<Metrowerks::has_nothrow_default_ctor<T>::value> {};
|
||||
|
||||
template <typename T> struct is_copy_constructible;
|
||||
template <typename T> struct is_trivially_copy_constructible
|
||||
: public bool_constant<Metrowerks::has_trivial_copy_ctor<T>::value> {};
|
||||
template <typename T> struct is_nothrow_copy_constructible
|
||||
: public bool_constant<Metrowerks::has_nothrow_copy_ctor<T>::value> {};
|
||||
|
||||
template <typename T> struct is_move_constructible : public false_type {}; // C++11
|
||||
template <typename T> struct is_trivially_move_constructible : public false_type {}; // C++11
|
||||
template <typename T> struct is_nothrow_move_constructible : public false_type {}; // C++11
|
||||
|
||||
template <typename T, typename U> struct is_assignable;
|
||||
template <typename T, typename U> struct is_trivially_assignable;
|
||||
template <typename T, typename U> struct is_nothrow_assignable;
|
||||
|
||||
template <typename T> struct is_copy_assignable;
|
||||
template <typename T> struct is_trivially_copy_assignable
|
||||
: public bool_constant<Metrowerks::has_trivial_assignment<T>::value> {};
|
||||
template <typename T> struct is_nothrow_copy_assignable
|
||||
: public bool_constant<Metrowerks::has_nothrow_assignment<T>::value> {};
|
||||
|
||||
template <typename T> struct is_move_assignable : public false_type {}; // C++11
|
||||
template <typename T> struct is_trivially_move_assignable : public false_type {}; // C++11
|
||||
template <typename T> struct is_nothrow_move_assignable : public false_type {}; // C++11
|
||||
|
||||
template <typename T> struct is_destructible;
|
||||
template <typename T> struct is_trivially_destructible
|
||||
: public bool_constant<Metrowerks::has_trivial_dtor<T>::value> {};
|
||||
template <typename T> struct is_nothrow_destructible
|
||||
: public bool_constant<Metrowerks::has_nothrow_dtor<T>::value> {};
|
||||
|
||||
template <typename T> struct has_virtual_destructor
|
||||
: public bool_constant<Metrowerks::has_virtual_dtor<T>::value> {};
|
||||
#pragma endregion
|
||||
|
||||
#pragma region "type property queries"
|
||||
template <typename T>
|
||||
struct alignment_of : public integral_constant<size_t, Metrowerks::alignment_of<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
struct rank : public integral_constant<size_t, 0> {};
|
||||
template <typename T>
|
||||
struct rank<T[]> : public integral_constant<size_t, rank<T>::value + 1> {};
|
||||
template <typename T, size_t N>
|
||||
struct rank<T[N]> : public integral_constant<size_t, rank<T>::value + 1> {};
|
||||
|
||||
template <typename T, unsigned N = 0>
|
||||
struct extent : public integral_constant<size_t, 0> {};
|
||||
template <typename T>
|
||||
struct extent<T[], 0> : public integral_constant<size_t, 0> {};
|
||||
template <typename T, unsigned N>
|
||||
struct extent<T[], N> : public extent<T, N - 1> {};
|
||||
template <typename T, size_t I>
|
||||
struct extent<T[I], 0> : public integral_constant<size_t, I> {};
|
||||
template <typename T, size_t I, unsigned N>
|
||||
struct extent<T[I], N> : public extent<T, N - 1> {};
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_RELATIONSHIP
|
||||
#define _MSL_TYPE_TRAITS_RELATIONSHIP
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include "type_traits/integral_constant.hpp"
|
||||
#include "type_traits/utility.hpp"
|
||||
|
||||
// clang-format off: conciseness
|
||||
namespace std {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename From, typename To>
|
||||
struct is_convertible {
|
||||
static true_type test(To) { __MWERKS_NOEVAL; }
|
||||
static false_type test(...) { __MWERKS_NOEVAL; }
|
||||
|
||||
#ifdef DECOMP_IDE_FLAG
|
||||
typedef false_type type;
|
||||
#else
|
||||
typedef __decltype__(test(declval<From>())) type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename Base, typename Derived>
|
||||
struct is_base_of {
|
||||
static true_type test(const volatile Base*) { __MWERKS_NOEVAL; }
|
||||
static false_type test(const volatile void*) { __MWERKS_NOEVAL; }
|
||||
|
||||
#ifdef DECOMP_IDE_FLAG
|
||||
typedef false_type type;
|
||||
#else
|
||||
typedef __decltype__(test(declval<Derived*>())) type;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
struct is_same : public false_type {};
|
||||
template <typename T>
|
||||
struct is_same<T, T> : public true_type {};
|
||||
|
||||
template <typename From, typename To>
|
||||
struct is_convertible : public detail::is_convertible<From, To> {};
|
||||
|
||||
template <typename Base, typename Derived>
|
||||
struct is_base_of : public detail::is_base_of<Base, Derived> {};
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef _MSL_TYPE_TRAITS_UTILITY
|
||||
#define _MSL_TYPE_TRAITS_UTILITY
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
// clang-format off: conciseness
|
||||
|
||||
#ifdef DECOMP_IDE_FLAG
|
||||
#define __static_assert(cond, msg)
|
||||
#endif
|
||||
|
||||
// #define __MWERKS_NOEVAL __static_assert(false, "Cannot be called from an evaluated context!")
|
||||
#define __MWERKS_NOEVAL
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
static T declval() { __MWERKS_NOEVAL; }
|
||||
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef _STD_TYPEINFO
|
||||
#define _STD_TYPEINFO
|
||||
|
||||
// from rb3 decomp
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
|
||||
namespace std {
|
||||
|
||||
class type_info {
|
||||
public:
|
||||
/*virtual*/ ~type_info();
|
||||
bool operator==(const type_info &rhs) const {
|
||||
return strcmp((char *) this->m_Name, (char *) rhs.m_Name) == 0;
|
||||
}
|
||||
|
||||
bool before(const type_info &rhs) const throw();
|
||||
size_t hash_code() const throw() {
|
||||
return m_HashCode;
|
||||
}
|
||||
const char *name() const throw() {
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
private:
|
||||
// These constructors are normally deleted, but our C++ version
|
||||
// doesn't support that, so they're privated as a workaround
|
||||
type_info();
|
||||
type_info(const type_info &);
|
||||
type_info &operator=(const type_info &);
|
||||
|
||||
const char *m_Name;
|
||||
size_t m_HashCode;
|
||||
};
|
||||
|
||||
class bad_cast : public exception {
|
||||
public:
|
||||
virtual ~bad_cast() {}
|
||||
virtual const char *what() const {
|
||||
return "bad_cast";
|
||||
}
|
||||
};
|
||||
|
||||
class bad_typeid : public exception {
|
||||
public:
|
||||
virtual ~bad_typeid() {}
|
||||
virtual const char *what() const {
|
||||
return "bad_typeid";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
+544
-5
@@ -1,10 +1,549 @@
|
||||
#pragma once
|
||||
#ifndef _STD_VECTOR
|
||||
#define _STD_VECTOR
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <compressed_pair.hpp>
|
||||
#include <msl_unk.hpp>
|
||||
|
||||
#define TAG_UNK 0
|
||||
|
||||
// from key decomp
|
||||
|
||||
namespace std {
|
||||
template <class T> class vector {
|
||||
template <bool> class __vector_common {
|
||||
public:
|
||||
T *elements;
|
||||
int size;
|
||||
int capacity;
|
||||
static void throw_length_error();
|
||||
};
|
||||
|
||||
template <typename T, class Allocator> class __vec_deleter_helper;
|
||||
|
||||
template <typename T, class Allocator> class __vec_deleter {
|
||||
public:
|
||||
typedef typename Metrowerks::compressed_pair<size_t, Allocator>::second_param allocator_param;
|
||||
typedef T value_type;
|
||||
typedef Allocator allocator_type;
|
||||
typedef size_t size_type;
|
||||
typedef value_type &reference;
|
||||
typedef const value_type &const_reference;
|
||||
typedef T *iterator;
|
||||
typedef const T *const_iterator;
|
||||
typedef T *pointer;
|
||||
typedef const pointer const_pointer;
|
||||
|
||||
__vec_deleter() :
|
||||
data_(nullptr),
|
||||
size_(0),
|
||||
capacity_(0) {}
|
||||
|
||||
explicit __vec_deleter(allocator_param a) :
|
||||
data_(nullptr),
|
||||
size_(0),
|
||||
capacity_(0, a) {}
|
||||
|
||||
~__vec_deleter();
|
||||
|
||||
reference operator[](size_t n) {
|
||||
return data_[n];
|
||||
}
|
||||
|
||||
const_reference operator[](size_t n) const {
|
||||
return data_[n];
|
||||
}
|
||||
|
||||
pointer data() {
|
||||
return data_;
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return data_;
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
reference front() {
|
||||
return data_[0];
|
||||
}
|
||||
|
||||
const_reference front() const {
|
||||
return data_[0];
|
||||
}
|
||||
|
||||
reference back() {
|
||||
return data_[size_ - 1];
|
||||
}
|
||||
|
||||
const_reference back() const {
|
||||
return data_[size_ - 1];
|
||||
}
|
||||
|
||||
void throw_length_error();
|
||||
|
||||
#if DONT_INLINE_STD
|
||||
void clear() {
|
||||
bool _b[4];
|
||||
size_t size = size_;
|
||||
_b[0] = false;
|
||||
erase_at_end(size, _b[0]);
|
||||
}
|
||||
void erase_at_end(size_t, bool &);
|
||||
#else
|
||||
void erase_at_end(const size_t n) {
|
||||
// erase_at_end(n, Metrowerks::int2type<true>());
|
||||
size_ -= n;
|
||||
}
|
||||
void clear() {
|
||||
erase_at_end(size());
|
||||
}
|
||||
#endif
|
||||
|
||||
// void erase_at_end(size_t n, Metrowerks::int2type<true>) DONT_INLINE_CLASS {
|
||||
// T* e = end();
|
||||
// size_ -= n;
|
||||
|
||||
// while (n != 0) {
|
||||
// e--;
|
||||
// e->~T();
|
||||
// n--;
|
||||
// }
|
||||
// }
|
||||
|
||||
size_t &cap() {
|
||||
return capacity_.first();
|
||||
}
|
||||
|
||||
Allocator alloc() const {
|
||||
return capacity_.second();
|
||||
}
|
||||
|
||||
iterator erase(iterator __first, iterator __last, UnkMSLStruct1);
|
||||
|
||||
void sub_push_back(const_reference x, Metrowerks::int2type<false>);
|
||||
void sub_push_back(const_reference x, Metrowerks::int2type<true>);
|
||||
|
||||
void sub_push_back(const_reference x) {
|
||||
sub_push_back(x, Metrowerks::int2type<Metrowerks::has_trivial_copy_ctor<T>::value &&
|
||||
Metrowerks::has_trivial_assignment<T>::value>());
|
||||
}
|
||||
|
||||
void push_back(const_reference x, Metrowerks::int2type<false>) {
|
||||
if (size_ < cap()) {
|
||||
alloc().construct(end(), x);
|
||||
size_++;
|
||||
} else {
|
||||
sub_push_back(x);
|
||||
}
|
||||
}
|
||||
|
||||
void push_back(const_reference x, Metrowerks::int2type<true>) {
|
||||
if (size_ < cap()) {
|
||||
size_++;
|
||||
back() = x;
|
||||
} else {
|
||||
sub_push_back(x);
|
||||
}
|
||||
}
|
||||
|
||||
void push_back(const_reference x) {
|
||||
push_back(x, Metrowerks::int2type<Metrowerks::has_trivial_copy_ctor<T>::value &&
|
||||
Metrowerks::has_trivial_assignment<T>::value>());
|
||||
}
|
||||
|
||||
void allocate(size_t min, size_t max) {
|
||||
allocate(min, max, Metrowerks::int2type<true>());
|
||||
}
|
||||
|
||||
void allocate(size_t min, size_t max, Metrowerks::int2type<true> t) {
|
||||
allocate(max, t);
|
||||
}
|
||||
|
||||
void allocate(size_t n) {
|
||||
allocate(n, Metrowerks::int2type<true>());
|
||||
}
|
||||
|
||||
void allocate(size_t n, Metrowerks::int2type<true> t);
|
||||
|
||||
void optimize_after_moved_from() {
|
||||
optimize_after_moved_from(Metrowerks::int2type<true>());
|
||||
}
|
||||
|
||||
void optimize_after_moved_from(Metrowerks::int2type<true>) {
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
bool expand_by(size_t n) {
|
||||
size_t max_cap = 0;
|
||||
return expand_by(n, max_cap, Metrowerks::int2type<true>());
|
||||
}
|
||||
|
||||
bool expand_by(size_t n, size_t &max_cap, Metrowerks::int2type<true>) {
|
||||
max_cap = grow_by(n);
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t grow_by(size_t n);
|
||||
|
||||
void append_realloc(size_t n, const_reference x);
|
||||
|
||||
size_t max_size() const {
|
||||
return alloc().max_size();
|
||||
}
|
||||
|
||||
size_t capacity() const {
|
||||
return capacity_.first();
|
||||
}
|
||||
|
||||
volatile size_t size() {
|
||||
return size_;
|
||||
}
|
||||
|
||||
void resize(size_t n) {
|
||||
size_ = n;
|
||||
}
|
||||
|
||||
void move_construct_to_end(iterator begin, iterator end);
|
||||
|
||||
void reallocate_copy(size_t n) {
|
||||
__vec_deleter<T, Allocator> tmp(alloc());
|
||||
tmp.allocate(n);
|
||||
tmp.move_construct_to_end(begin(), end());
|
||||
optimize_after_moved_from();
|
||||
swap(cap(), tmp.cap());
|
||||
swap(data_, tmp.data_);
|
||||
swap(size_, tmp.size_);
|
||||
}
|
||||
|
||||
void reserve(size_t n) {
|
||||
if (n > cap()) {
|
||||
reallocate_copy(n);
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return size_ == 0;
|
||||
}
|
||||
|
||||
public:
|
||||
T *data_;
|
||||
size_t size_;
|
||||
Metrowerks::compressed_pair<size_t, Allocator> capacity_;
|
||||
};
|
||||
|
||||
template <typename T, typename Allocator> __vec_deleter<T, Allocator>::~__vec_deleter() {
|
||||
UnkMSLStruct1 unk = UnkMSLStruct1(); // somehow needed
|
||||
|
||||
if (data_ != nullptr) {
|
||||
clear();
|
||||
alloc().deallocate(data_, cap());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator> size_t __vec_deleter<T, Allocator>::grow_by(size_t n) {
|
||||
size_t max = max_size();
|
||||
size_t c = cap();
|
||||
|
||||
if (n > max - c) {
|
||||
__vector_common<true>::throw_length_error();
|
||||
}
|
||||
|
||||
size_t a = max / 3;
|
||||
|
||||
if (c < a) {
|
||||
return c + std::max((c + 1) * 3 / 5, n);
|
||||
} else if (c < a * 2) {
|
||||
return c + std::max((c + 1) / 2, n);
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
void __vec_deleter<T, Allocator>::allocate(size_t n, Metrowerks::int2type<true> t) {
|
||||
size_t max = max_size();
|
||||
|
||||
if (max < n) {
|
||||
__vector_common<true>::throw_length_error();
|
||||
}
|
||||
|
||||
data_ = alloc().allocate(n);
|
||||
cap() = n;
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/Yw4fn
|
||||
template <typename T, typename Allocator> void __vec_deleter<T, Allocator>::append_realloc(size_t n, const_reference x) {
|
||||
__vec_deleter_helper<T, Allocator> tmp(alloc());
|
||||
|
||||
size_t max = tmp.grow_by((size_ + n) - cap());
|
||||
tmp.allocate(size_ + n, max);
|
||||
tmp.start_ = size_;
|
||||
tmp.construct_at_end(n, x);
|
||||
tmp.move_construct_to_begin(begin(), end());
|
||||
optimize_after_moved_from();
|
||||
|
||||
std::swap(cap(), tmp.cap());
|
||||
std::swap(data_, tmp.data_);
|
||||
std::swap(size_, tmp.size_);
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
void __vec_deleter<T, Allocator>::sub_push_back(const_reference x, Metrowerks::int2type<TAG_UNK>) {
|
||||
if (expand_by(1)) {
|
||||
size_++;
|
||||
back() = x;
|
||||
} else {
|
||||
append_realloc(1, x);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
void __vec_deleter<T, Allocator>::sub_push_back(const_reference x, Metrowerks::int2type<true>) {
|
||||
if (expand_by(1)) {
|
||||
size_++;
|
||||
back() = x;
|
||||
} else {
|
||||
append_realloc(1, x);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
__vec_deleter<T, Allocator>::iterator __vec_deleter<T, Allocator>::erase(iterator __first, iterator __last,
|
||||
UnkMSLStruct1) {
|
||||
// adapted from https://github.com/matta/sgi-stl/blob/635eaeef4533214ec140fb17411558ad441d2996/stl/stl_vector.h#L420
|
||||
|
||||
if (__first != __last) {
|
||||
std::memmove(__first, __last, (end() - __last) * sizeof(value_type));
|
||||
this->size_ -= __last - __first;
|
||||
}
|
||||
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <typename T, class Allocator> class __vec_deleter_helper : public __vec_deleter<T, Allocator> {
|
||||
protected:
|
||||
typedef __vec_deleter<T, Allocator> _Base;
|
||||
typedef _Base::allocator_param allocator_param;
|
||||
typedef _Base::value_type value_type;
|
||||
typedef _Base::allocator_type allocator_type;
|
||||
typedef _Base::size_type size_type;
|
||||
typedef _Base::reference reference;
|
||||
typedef _Base::const_reference const_reference;
|
||||
typedef _Base::pointer pointer;
|
||||
typedef _Base::const_pointer const_pointer;
|
||||
typedef _Base::iterator iterator;
|
||||
typedef _Base::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
__vec_deleter_helper(allocator_param a) :
|
||||
_Base(a),
|
||||
start_(0) {}
|
||||
|
||||
~__vec_deleter_helper();
|
||||
|
||||
void construct_at_end(size_t n, const_reference x) {
|
||||
construct_at_end(n, x, Metrowerks::int2type<Metrowerks::has_trivial_copy_ctor<T>::value>());
|
||||
}
|
||||
|
||||
void construct_at_end(size_t n, const_reference x, Metrowerks::int2type<TAG_UNK>) {
|
||||
for (pointer p = _Base::data_ + _Base::size_; n; n--, p++, _Base::size_++) {
|
||||
_Base::alloc().construct(p, x);
|
||||
}
|
||||
}
|
||||
|
||||
void construct_at_end(size_t n, const_reference x, Metrowerks::int2type<true>) {
|
||||
std::fill_n(_Base::data_ + start_ + _Base::size_, n, x);
|
||||
_Base::size_ += n;
|
||||
}
|
||||
|
||||
void move_construct_to_begin(pointer first, pointer last) {
|
||||
move_construct_to_begin(first, last, Metrowerks::int2type<Metrowerks::has_trivial_copy_ctor<T>::value ? 2 : 0>());
|
||||
}
|
||||
|
||||
void move_construct_to_begin(pointer first, pointer last, Metrowerks::int2type<TAG_UNK>) {
|
||||
for (pointer ptr = _Base::data_ + start_; first < last; start_--, _Base::size_++) {
|
||||
_Base::alloc().construct(--ptr, std::move(*--last));
|
||||
}
|
||||
}
|
||||
|
||||
void move_construct_to_begin(pointer first, pointer last, Metrowerks::int2type<2>) {
|
||||
size_t n = last - first;
|
||||
start_ -= n;
|
||||
memcpy(_Base::data_ + start_, first, n * sizeof(value_type));
|
||||
memset(first, 0, n * sizeof(value_type));
|
||||
_Base::size_ += n;
|
||||
}
|
||||
|
||||
size_t start_;
|
||||
};
|
||||
|
||||
template <typename T, class Allocator> __vec_deleter_helper<T, Allocator>::~__vec_deleter_helper() {
|
||||
T *start = _Base::data_ + start_;
|
||||
T *end = start + _Base::size_;
|
||||
|
||||
while (start < end) {
|
||||
_Base::alloc().destroy(end);
|
||||
end--;
|
||||
}
|
||||
|
||||
_Base::size_ = 0;
|
||||
}
|
||||
|
||||
template <typename T, class Allocator, bool I> class __vec_constructor : public __vec_deleter<T, Allocator> {
|
||||
protected:
|
||||
typedef __vec_deleter<T, Allocator> _Base;
|
||||
typedef _Base::allocator_param allocator_param;
|
||||
typedef _Base::value_type value_type;
|
||||
typedef _Base::allocator_type allocator_type;
|
||||
typedef _Base::size_type size_type;
|
||||
typedef _Base::reference reference;
|
||||
typedef _Base::const_reference const_reference;
|
||||
typedef _Base::pointer pointer;
|
||||
typedef _Base::const_pointer const_pointer;
|
||||
typedef _Base::iterator iterator;
|
||||
typedef _Base::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
__vec_constructor() {}
|
||||
// ~__vec_constructor();
|
||||
};
|
||||
|
||||
template <typename T, class Allocator>
|
||||
class __vec_constructor<T, Allocator, true> : public __vec_constructor<T, Allocator, false> {
|
||||
protected:
|
||||
typedef __vec_deleter<T, Allocator> _Deleter;
|
||||
typedef __vec_constructor<T, Allocator, false> _Constructor;
|
||||
typedef _Constructor::allocator_param allocator_param;
|
||||
typedef _Constructor::value_type value_type;
|
||||
typedef _Constructor::allocator_type allocator_type;
|
||||
typedef _Constructor::size_type size_type;
|
||||
typedef _Constructor::reference reference;
|
||||
typedef _Constructor::const_reference const_reference;
|
||||
typedef _Constructor::pointer pointer;
|
||||
typedef _Constructor::const_pointer const_pointer;
|
||||
typedef _Constructor::iterator iterator;
|
||||
typedef _Constructor::const_iterator const_iterator;
|
||||
|
||||
__vec_constructor() {}
|
||||
// ~__vec_constructor() { }
|
||||
|
||||
public:
|
||||
void push_back(const_reference x) {
|
||||
_Constructor::push_back(x);
|
||||
}
|
||||
|
||||
reference operator[](size_t n) {
|
||||
return _Deleter::operator[](n);
|
||||
}
|
||||
|
||||
const_reference operator[](size_t n) const {
|
||||
return _Deleter::operator[](n);
|
||||
}
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
template <typename T, typename Allocator = allocator<T> > class vector : public __vec_constructor<T, Allocator, true> {
|
||||
// clang-format on
|
||||
protected:
|
||||
typedef __vec_constructor<T, Allocator, true> _Constructor;
|
||||
typedef __vec_deleter<T, Allocator> _Deleter;
|
||||
typedef _Constructor::allocator_param allocator_param;
|
||||
typedef _Constructor::value_type value_type;
|
||||
typedef _Constructor::allocator_type allocator_type;
|
||||
typedef _Constructor::size_type size_type;
|
||||
typedef _Constructor::reference reference;
|
||||
typedef _Constructor::const_reference const_reference;
|
||||
typedef _Constructor::pointer pointer;
|
||||
typedef _Constructor::const_pointer const_pointer;
|
||||
|
||||
public:
|
||||
typedef _Constructor::iterator iterator;
|
||||
typedef _Constructor::const_iterator const_iterator;
|
||||
|
||||
vector() {}
|
||||
~vector() { }
|
||||
|
||||
void push_back(const_reference x) {
|
||||
_Constructor::push_back(x);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Deleter::clear();
|
||||
}
|
||||
|
||||
reference operator[](size_t n) {
|
||||
return _Deleter::operator[](n);
|
||||
}
|
||||
|
||||
const_reference operator[](size_t n) const {
|
||||
return _Deleter::operator[](n);
|
||||
}
|
||||
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
return _Deleter::erase(__first, __last, UnkMSLStruct1());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
template <typename T> class CustomVector : public std::vector<T> {
|
||||
public:
|
||||
protected:
|
||||
typedef std::vector<T> _Vector;
|
||||
typedef _Vector::allocator_param allocator_param;
|
||||
typedef _Vector::value_type value_type;
|
||||
typedef _Vector::allocator_type allocator_type;
|
||||
typedef _Vector::size_type size_type;
|
||||
typedef _Vector::reference reference;
|
||||
typedef _Vector::const_reference const_reference;
|
||||
typedef _Vector::pointer pointer;
|
||||
typedef _Vector::const_pointer const_pointer;
|
||||
|
||||
public:
|
||||
typedef _Vector::iterator iterator;
|
||||
typedef _Vector::const_iterator const_iterator;
|
||||
|
||||
~CustomVector();
|
||||
|
||||
iterator unk_action2(iterator begin, iterator end, UnkMSLStruct1) {
|
||||
iterator it = begin;
|
||||
|
||||
while (it != end) {
|
||||
T *ptr = (T *) *it;
|
||||
|
||||
if (ptr != NULL) {
|
||||
if (*((u8 *) ptr + 4)) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
*it = NULL;
|
||||
}
|
||||
|
||||
it++;
|
||||
begin = this->begin();
|
||||
end = this->end();
|
||||
}
|
||||
|
||||
return std::remove(begin, end, (T) NULL);
|
||||
}
|
||||
|
||||
void unk_action1() {
|
||||
this->erase(this->unk_action2(this->begin(), this->end(), UnkMSLStruct1()), this->end());
|
||||
this->clear();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> CustomVector<T>::~CustomVector() {
|
||||
UnkMSLStruct1 unk = UnkMSLStruct1(); // somehow needed
|
||||
|
||||
if (_Vector::begin() != nullptr) {
|
||||
_Vector::clear();
|
||||
_Vector::alloc().deallocate(_Vector::begin(), _Vector::cap());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user