aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/kiwisolver/py3/kiwi/shareddata.h
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2023-12-08 17:43:34 +0300
committershadchin <shadchin@yandex-team.com>2023-12-08 20:15:01 +0300
commit213cda016d72c7d8d0e55ac7a7351959fa6ca2b8 (patch)
treea0a9170141dd91d1ff0727c0faa1af58d7b81133 /contrib/python/kiwisolver/py3/kiwi/shareddata.h
parent914f57e3243f53dd89dd3adb4d8b6d35c47f46ce (diff)
downloadydb-213cda016d72c7d8d0e55ac7a7351959fa6ca2b8.tar.gz
Update kiwisolver to 1.2.0
Diffstat (limited to 'contrib/python/kiwisolver/py3/kiwi/shareddata.h')
-rw-r--r--contrib/python/kiwisolver/py3/kiwi/shareddata.h246
1 files changed, 120 insertions, 126 deletions
diff --git a/contrib/python/kiwisolver/py3/kiwi/shareddata.h b/contrib/python/kiwisolver/py3/kiwi/shareddata.h
index b7d389ee6d..9b1bc2c012 100644
--- a/contrib/python/kiwisolver/py3/kiwi/shareddata.h
+++ b/contrib/python/kiwisolver/py3/kiwi/shareddata.h
@@ -3,11 +3,10 @@
|
| Distributed under the terms of the Modified BSD License.
|
-| The full license is in the file COPYING.txt, distributed with this software.
+| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
#pragma once
-
namespace kiwi
{
@@ -15,143 +14,138 @@ class SharedData
{
public:
+ SharedData() : m_refcount(0) {}
- SharedData() : m_refcount( 0 ) {}
-
- SharedData( const SharedData& other ) : m_refcount( 0 ) {}
+ SharedData(const SharedData &other) : m_refcount(0) {}
int m_refcount;
private:
-
- SharedData& operator=( const SharedData& other );
+ SharedData &operator=(const SharedData &other);
};
-
-template<typename T>
+template <typename T>
class SharedDataPtr
{
public:
-
- typedef T Type;
-
- SharedDataPtr() : m_data( 0 ) {}
-
- explicit SharedDataPtr( T* data ) : m_data( data )
- {
- incref( m_data );
- }
-
- ~SharedDataPtr()
- {
- decref( m_data );
- }
-
- T* data()
- {
- return m_data;
- }
-
- const T* data() const
- {
- return m_data;
- }
-
- operator T*()
- {
- return m_data;
- }
-
- operator const T*() const
- {
- return m_data;
- }
-
- T* operator->()
- {
- return m_data;
- }
-
- const T* operator->() const
- {
- return m_data;
- }
-
- T& operator*()
- {
- return *m_data;
- }
-
- const T& operator*() const
- {
- return *m_data;
- }
-
- bool operator!() const
- {
- return !m_data;
- }
-
- bool operator<( const SharedDataPtr<T>& other ) const
- {
- return m_data < other.m_data;
- }
-
- bool operator==( const SharedDataPtr<T>& other ) const
- {
- return m_data == other.m_data;
- }
-
- bool operator!=( const SharedDataPtr<T>& other ) const
- {
- return m_data != other.m_data;
- }
-
- SharedDataPtr( const SharedDataPtr<T>& other ) : m_data( other.m_data )
- {
- incref( m_data );
- }
-
- SharedDataPtr<T>& operator=( const SharedDataPtr<T>& other )
- {
- if( m_data != other.m_data )
- {
- T* temp = m_data;
- m_data = other.m_data;
- incref( m_data );
- decref( temp );
- }
- return *this;
- }
-
- SharedDataPtr<T>& operator=( T* other )
- {
- if( m_data != other )
- {
- T* temp = m_data;
- m_data = other;
- incref( m_data );
- decref( temp );
- }
- return *this;
- }
+ typedef T Type;
+
+ SharedDataPtr() : m_data(0) {}
+
+ explicit SharedDataPtr(T *data) : m_data(data)
+ {
+ incref(m_data);
+ }
+
+ ~SharedDataPtr()
+ {
+ decref(m_data);
+ }
+
+ T *data()
+ {
+ return m_data;
+ }
+
+ const T *data() const
+ {
+ return m_data;
+ }
+
+ operator T *()
+ {
+ return m_data;
+ }
+
+ operator const T *() const
+ {
+ return m_data;
+ }
+
+ T *operator->()
+ {
+ return m_data;
+ }
+
+ const T *operator->() const
+ {
+ return m_data;
+ }
+
+ T &operator*()
+ {
+ return *m_data;
+ }
+
+ const T &operator*() const
+ {
+ return *m_data;
+ }
+
+ bool operator!() const
+ {
+ return !m_data;
+ }
+
+ bool operator<(const SharedDataPtr<T> &other) const
+ {
+ return m_data < other.m_data;
+ }
+
+ bool operator==(const SharedDataPtr<T> &other) const
+ {
+ return m_data == other.m_data;
+ }
+
+ bool operator!=(const SharedDataPtr<T> &other) const
+ {
+ return m_data != other.m_data;
+ }
+
+ SharedDataPtr(const SharedDataPtr<T> &other) : m_data(other.m_data)
+ {
+ incref(m_data);
+ }
+
+ SharedDataPtr<T> &operator=(const SharedDataPtr<T> &other)
+ {
+ if (m_data != other.m_data)
+ {
+ T *temp = m_data;
+ m_data = other.m_data;
+ incref(m_data);
+ decref(temp);
+ }
+ return *this;
+ }
+
+ SharedDataPtr<T> &operator=(T *other)
+ {
+ if (m_data != other)
+ {
+ T *temp = m_data;
+ m_data = other;
+ incref(m_data);
+ decref(temp);
+ }
+ return *this;
+ }
private:
-
- static void incref( T* data )
- {
- if( data )
- ++data->m_refcount;
- }
-
- static void decref( T* data )
- {
- if( data && --data->m_refcount == 0 )
- delete data;
- }
-
- T* m_data;
+ static void incref(T *data)
+ {
+ if (data)
+ ++data->m_refcount;
+ }
+
+ static void decref(T *data)
+ {
+ if (data && --data->m_refcount == 0)
+ delete data;
+ }
+
+ T *m_data;
};
} // namespace kiwi