mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-22 14:23:59 -07:00
drop namespace from std::size_t and std::ptrdiff_t
the C and C++ definitions identical, but they might not be defined in std for some alternative stdc++ libraries
This commit is contained in:
parent
9d6bd920ed
commit
acd77a5441
3 changed files with 15 additions and 11 deletions
|
@ -33,6 +33,8 @@
|
||||||
#include "IpcListener.hpp"
|
#include "IpcListener.hpp"
|
||||||
#include "NodeControlService.hpp"
|
#include "NodeControlService.hpp"
|
||||||
|
|
||||||
|
#include "stddef.h"
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
|
@ -31,12 +31,14 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "stddef.h"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static array -- a simple thing that's belonged in STL since the time of the dinosaurs
|
* Static array -- a simple thing that's belonged in STL since the time of the dinosaurs
|
||||||
*/
|
*/
|
||||||
template<typename T,std::size_t S>
|
template<typename T,size_t S>
|
||||||
class Array
|
class Array
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -44,19 +46,19 @@ public:
|
||||||
|
|
||||||
Array(const Array &a)
|
Array(const Array &a)
|
||||||
{
|
{
|
||||||
for(std::size_t i=0;i<S;++i)
|
for(size_t i=0;i<S;++i)
|
||||||
data[i] = a.data[i];
|
data[i] = a.data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Array(const T *ptr)
|
Array(const T *ptr)
|
||||||
{
|
{
|
||||||
for(std::size_t i=0;i<S;++i)
|
for(size_t i=0;i<S;++i)
|
||||||
data[i] = ptr[i];
|
data[i] = ptr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Array &operator=(const Array &a)
|
inline Array &operator=(const Array &a)
|
||||||
{
|
{
|
||||||
for(std::size_t i=0;i<S;++i)
|
for(size_t i=0;i<S;++i)
|
||||||
data[i] = a.data[i];
|
data[i] = a.data[i];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +70,8 @@ public:
|
||||||
typedef const T& const_reference;
|
typedef const T& const_reference;
|
||||||
typedef T* iterator;
|
typedef T* iterator;
|
||||||
typedef const T* const_iterator;
|
typedef const T* const_iterator;
|
||||||
typedef std::size_t size_type;
|
typedef size_t size_type;
|
||||||
typedef std::ptrdiff_t difference_type;
|
typedef ptrdiff_t difference_type;
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
|
@ -83,11 +85,11 @@ public:
|
||||||
inline const_reverse_iterator rbegin() const throw() { return const_reverse_iterator(begin()); }
|
inline const_reverse_iterator rbegin() const throw() { return const_reverse_iterator(begin()); }
|
||||||
inline const_reverse_iterator rend() const throw() { return const_reverse_iterator(end()); }
|
inline const_reverse_iterator rend() const throw() { return const_reverse_iterator(end()); }
|
||||||
|
|
||||||
inline std::size_t size() const throw() { return S; }
|
inline size_t size() const throw() { return S; }
|
||||||
inline std::size_t max_size() const throw() { return S; }
|
inline size_t max_size() const throw() { return S; }
|
||||||
|
|
||||||
inline reference operator[](const std::size_t n) throw() { return data[n]; }
|
inline reference operator[](const size_t n) throw() { return data[n]; }
|
||||||
inline const_reference operator[](const std::size_t n) const throw() { return data[n]; }
|
inline const_reference operator[](const size_t n) const throw() { return data[n]; }
|
||||||
|
|
||||||
inline reference front() throw() { return data[0]; }
|
inline reference front() throw() { return data[0]; }
|
||||||
inline const_reference front() const throw() { return data[0]; }
|
inline const_reference front() const throw() { return data[0]; }
|
||||||
|
|
|
@ -137,7 +137,7 @@ std::string InetAddress::toString() const
|
||||||
|
|
||||||
void InetAddress::fromString(const std::string &ipSlashPort)
|
void InetAddress::fromString(const std::string &ipSlashPort)
|
||||||
{
|
{
|
||||||
std::size_t slashAt = ipSlashPort.find('/');
|
size_t slashAt = ipSlashPort.find('/');
|
||||||
if ((slashAt == std::string::npos)||(slashAt >= ipSlashPort.length()))
|
if ((slashAt == std::string::npos)||(slashAt >= ipSlashPort.length()))
|
||||||
set(ipSlashPort,0);
|
set(ipSlashPort,0);
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue