mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
merge some changes from develop branch; modernize and clean-up code; remove support for compiling without POCO_WIN32_UTF8
This commit is contained in:
@@ -24,12 +24,15 @@
|
||||
#ifndef Foundation_Array_INCLUDED
|
||||
#define Foundation_Array_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Bugcheck.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
class Array
|
||||
/// STL container like C-style array replacement class.
|
||||
@@ -37,9 +40,7 @@ class Array
|
||||
/// This implementation is based on the idea of Nicolai Josuttis.
|
||||
/// His original implementation can be found at http://www.josuttis.com/cppcode/array.html .
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
@@ -158,7 +159,8 @@ public:
|
||||
|
||||
enum { static_size = N };
|
||||
|
||||
void swap (Array<T,N>& y) {
|
||||
void swap (Array<T,N>& y)
|
||||
{
|
||||
std::swap_ranges(begin(),end(),y.begin());
|
||||
}
|
||||
|
||||
@@ -173,7 +175,8 @@ public:
|
||||
return elems;
|
||||
}
|
||||
|
||||
T* c_array(){
|
||||
T* c_array()
|
||||
{
|
||||
/// Use array as C array (direct read/write access to data)
|
||||
return elems;
|
||||
}
|
||||
@@ -193,12 +196,12 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
T elems[N];
|
||||
/// Fixed-size array of elements of type T, public specifier used to make this class a aggregate.
|
||||
|
||||
};
|
||||
|
||||
|
||||
// comparisons
|
||||
template<class T, std::size_t N>
|
||||
bool operator== (const Array<T,N>& x, const Array<T,N>& y)
|
||||
@@ -206,36 +209,42 @@ bool operator== (const Array<T,N>& x, const Array<T,N>& y)
|
||||
return std::equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
bool operator< (const Array<T,N>& x, const Array<T,N>& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
bool operator!= (const Array<T,N>& x, const Array<T,N>& y)
|
||||
{
|
||||
return !(x==y);
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
bool operator> (const Array<T,N>& x, const Array<T,N>& y)
|
||||
{
|
||||
return y<x;
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
bool operator<= (const Array<T,N>& x, const Array<T,N>& y)
|
||||
{
|
||||
return !(y<x);
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
bool operator>= (const Array<T,N>& x, const Array<T,N>& y)
|
||||
{
|
||||
return !(x<y);
|
||||
}
|
||||
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline void swap (Array<T,N>& x, Array<T,N>& y)
|
||||
/// global swap()
|
||||
@@ -243,7 +252,9 @@ inline void swap (Array<T,N>& x, Array<T,N>& y)
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
|
||||
}// namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Array_INCLUDED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user