[+] Added AU_DEFINE_FOR_VA, AU_DEFINE_THIS_MOVE_CTOR_VA, AU_DEFINE_THIS_COPY_CTOR_VA
This commit is contained in:
parent
10becf180c
commit
68ab966315
@ -214,6 +214,24 @@
|
||||
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_CPY, AU_EMIT_CTOR_CPY_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
|
||||
{}
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_EMIT_CTOR_ASSIGN2(pair) pair(cpy.pair)
|
||||
/// @hideinitializer
|
||||
#define AU_EMIT_CTOR_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_ASSIGN2(pair)
|
||||
|
||||
#define AU_DEFINE_THIS_COPY_CTOR_VA(thisType, args) \
|
||||
inline thisType(const thisType &cpy) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN2, AU_EMIT_CTOR_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
|
||||
{}
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_EMIT_CTOR_MOVE_ASSIGN2(pair) pair(AuMove(cpy.pair))
|
||||
/// @hideinitializer
|
||||
#define AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND(pair) ,AU_EMIT_CTOR_MOVE_ASSIGN2(pair)
|
||||
|
||||
#define AU_DEFINE_THIS_MOVE_CTOR_VA(thisType, args) \
|
||||
inline thisType(thisType &&cpy) noexcept : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOVE_ASSIGN2, AU_EMIT_CTOR_MOVE_ASSIGN2_SECOND, AU_STRIP_BRACKETS(args)) \
|
||||
{}
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_DEFINE_CTOR_MOV_VA(thisType, args) \
|
||||
inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_STRIP_BRACKETS(args))) : AU_FOR_EACH_FIRST(AU_EMIT_CTOR_ASSIGN, AU_EMIT_CTOR_ASSIGN_SECOND, AU_STRIP_BRACKETS(args)) \
|
||||
@ -249,3 +267,25 @@ inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_
|
||||
|
||||
///
|
||||
#define AU_DEFINE_HASHCODE_VA(thisType, args) AuUInt HashCode() const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_HASHCODE_A, AU_DEFINE_EQUALS_HASHCODE_B, AU_STRIP_BRACKETS(args)) ; }
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_DEFINE_MOVE_VA_A(name) this->name = AuMove(ref.name);
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_DEFINE_MOVE_VA_B(name) AU_DEFINE_MOVE_VA_A(name)
|
||||
|
||||
///
|
||||
#define AU_DEFINE_MOVE_VA(thisType, args) thisType& operator=( thisType && ref) noexcept { AU_FOR_EACH_FIRST(AU_DEFINE_MOVE_VA_A, AU_DEFINE_MOVE_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
|
||||
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_DEFINE_COPY_VA_A(name) this->name = ref.name;
|
||||
|
||||
/// @hideinitializer
|
||||
#define AU_DEFINE_COPY_VA_B(name) AU_DEFINE_COPY_VA_A(name)
|
||||
|
||||
///
|
||||
#define AU_DEFINE_COPY_VA(thisType, args) thisType& operator=(const thisType & ref) { AU_FOR_EACH_FIRST(AU_DEFINE_COPY_VA_A, AU_DEFINE_COPY_VA_B, AU_STRIP_BRACKETS(args)) return *this; }
|
||||
|
||||
#define AU_DEFINE_FOR_VA_(pair, func) func(AU_EMIT_SECOND pair, AU_STRIP_BRACKETS(AU_EMIT_FIRST pair))
|
||||
#define AU_DEFINE_FOR_VA(type, arry, members) AU_FOR_EACH_THAT(AU_DEFINE_FOR_VA_, ((members), type), AU_STRIP_BRACKETS(arry))
|
@ -199,13 +199,13 @@ inline auto AuTryFindByTupleN(List &list, const Key &key)
|
||||
return list.end();
|
||||
}
|
||||
|
||||
template <class Range, class Key, AU_TEMPLATE_ENABLE_WHEN(!__audetail::AuHasfind_v<Range>)>
|
||||
template <class Range, class Key, AU_TEMPLATE_ENABLE_WHEN(!__audetail::AuHasfind_v<Range> && !AuIsPointer_v<Range>)>
|
||||
inline bool AuExists(const Range &a, const Key &key)
|
||||
{
|
||||
return std::find(a.begin(), a.end(), key) != a.end();
|
||||
}
|
||||
|
||||
template <class Map, class Key, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasfind_v<Map>)>
|
||||
template <class Map, class Key, AU_TEMPLATE_ENABLE_WHEN(__audetail::AuHasfind_v<Map> && !AuIsPointer_v<Map>)>
|
||||
inline bool AuExists(const Map &map, const Key &key)
|
||||
{
|
||||
auto itr = map.find(key);
|
||||
@ -315,7 +315,7 @@ inline bool AuTryInsert(Container &container, Key_t &&key, Type_t &&value)
|
||||
}
|
||||
else
|
||||
{
|
||||
itr->second = value;
|
||||
itr->second = AuMove(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -353,7 +353,7 @@ inline bool AuTryInsert(Container &container, const Key_t &key, Type_t &&value)
|
||||
}
|
||||
else
|
||||
{
|
||||
itr->second = value;
|
||||
itr->second = AuMove(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -475,25 +475,25 @@ inline bool AuTryInsert(Container &container, const Value &value)
|
||||
}
|
||||
|
||||
template <class Map, class Key, class Value>
|
||||
inline bool AuTryInsert(const Map *map, Key &&key, Value &&value)
|
||||
inline bool AuTryInsert(Map *map, Key &&key, Value &&value)
|
||||
{
|
||||
return AuTryInsert(*map, AuMove(key), AuMove(value));
|
||||
}
|
||||
|
||||
template <class Map, class Key, class Value>
|
||||
inline bool AuTryInsert(const Map *map, const Key &key, Value &&value)
|
||||
inline bool AuTryInsert(Map *map, const Key &key, Value &&value)
|
||||
{
|
||||
return AuTryInsert(*map, AuReference(key), AuMove(value));
|
||||
}
|
||||
|
||||
template <class Map, class Value>
|
||||
inline bool AuTryInsert(const Map *map, Value &&value)
|
||||
inline bool AuTryInsert(Map *map, Value &&value)
|
||||
{
|
||||
return AuTryInsert(*map, AuMove(value));
|
||||
}
|
||||
|
||||
template <class Map, class Value>
|
||||
inline bool AuTryInsert(const Map *map, const Value &value)
|
||||
inline bool AuTryInsert(Map *map, const Value &value)
|
||||
{
|
||||
return AuTryInsert(*map, value);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* @return
|
||||
*/
|
||||
template <class T>
|
||||
constexpr AuRemoveReference_t<T> &&AuMove(T &&arg)
|
||||
auline constexpr AuRemoveReference_t<T> &&AuMove(T &&arg) noexcept
|
||||
{
|
||||
return static_cast<AuRemoveReference_t<T> &&>(arg);
|
||||
}
|
||||
@ -28,7 +28,7 @@ constexpr AuRemoveReference_t<T> &&AuMove(T &&arg)
|
||||
* @return
|
||||
*/
|
||||
template <class T>
|
||||
constexpr T &AuReference(T &arg)
|
||||
auline constexpr T &AuReference(T &arg) noexcept
|
||||
{
|
||||
return static_cast<T &>(arg);
|
||||
}
|
||||
@ -40,7 +40,7 @@ constexpr T &AuReference(T &arg)
|
||||
* @return
|
||||
*/
|
||||
template <class T>
|
||||
constexpr T &&AuForward(AuRemoveReference_t<T> &arg)
|
||||
auline constexpr T &&AuForward(AuRemoveReference_t<T> &arg) noexcept
|
||||
{
|
||||
return static_cast<T &&>(arg);
|
||||
}
|
||||
@ -52,7 +52,7 @@ constexpr T &&AuForward(AuRemoveReference_t<T> &arg)
|
||||
* @return
|
||||
*/
|
||||
template <class T>
|
||||
constexpr T &&AuForward(AuRemoveReference_t<T> &&arg)
|
||||
auline constexpr T &&AuForward(AuRemoveReference_t<T> &&arg) noexcept
|
||||
{
|
||||
return static_cast<T &&>(arg);
|
||||
}
|
Loading…
Reference in New Issue
Block a user