make_signed/make_unsigned moved to clr_std/type_traits.
Removed pair.h and type_traits.h
Fix #27557
};
//-----------------------------------------------------------------------------------------
+ // TEMPLATE CLASS make_unsigned
+ template<typename Type1>
+ struct make_unsigned
+ {
+ };
+
+ template<>
+ struct make_unsigned<int>
+ {
+ typedef unsigned int type;
+ };
+
+#ifndef PLATFORM_UNIX
+
+ template<>
+ struct make_unsigned<long>
+ {
+ typedef unsigned long type;
+ };
+
+#endif // !PLATFORM_UNIX
+
+ template<>
+ struct make_unsigned<__int64>
+ {
+ typedef unsigned __int64 type;
+ };
+
+ template<>
+ struct make_unsigned<size_t>
+ {
+ typedef size_t type;
+ };
+
+ //-----------------------------------------------------------------------------------------
+ // TEMPLATE CLASS make_signed
+ template<typename Type1>
+ struct make_signed
+ {
+ };
+
+ template<>
+ struct make_signed<unsigned int>
+ {
+ typedef signed int type;
+ };
+
+#ifndef PLATFORM_UNIX
+
+ template<>
+ struct make_signed<unsigned long>
+ {
+ typedef signed long type;
+ };
+
+#endif // !PLATFORM_UNIX
+
+ template<>
+ struct make_signed<unsigned __int64>
+ {
+ typedef signed __int64 type;
+ };
+
+ //-----------------------------------------------------------------------------------------
// TEMPLATE CLASS is_lvalue_reference
template<class _Ty>
struct is_lvalue_reference
Realloc();
}
- new (&data[tosIndex], jitstd::placement_t()) T(jitstd::forward<Args>(args)...);
+ new (&data[tosIndex], jitstd::placement_t()) T(std::forward<Args>(args)...);
tosIndex++;
}
// Check for op1 or op2 to be lcl var and if so, keep it in op1.
if ((op1->gtOper != GT_LCL_VAR) && (op2->gtOper == GT_LCL_VAR))
{
- jitstd::swap(op1, op2);
+ std::swap(op1, op2);
}
// If op1 is lcl and op2 is const or lcl, create assertion.
if ((op1->gtOper == GT_LCL_VAR) &&
if (((op1->gtOper != GT_IND) || (op1->AsOp()->gtOp1->gtOper != GT_LCL_VAR)) &&
((op2->gtOper == GT_IND) && (op2->AsOp()->gtOp1->gtOper == GT_LCL_VAR)))
{
- jitstd::swap(op1, op2);
+ std::swap(op1, op2);
}
// If op1 is ind, then extract op1's oper.
if ((op1->gtOper == GT_IND) && (op1->AsOp()->gtOp1->gtOper == GT_LCL_VAR))
// Look for a call to an IsInstanceOf helper compared to a nullptr
if ((op2->gtOper != GT_CNS_INT) && (op1->gtOper == GT_CNS_INT))
{
- jitstd::swap(op1, op2);
+ std::swap(op1, op2);
}
// Validate op1 and op2
if ((op1->gtOper != GT_CALL) || (op1->AsCall()->gtCallType != CT_HELPER) || (op1->TypeGet() != TYP_REF) || // op1
{
// Swap res with head.
prev->flNext = head;
- jitstd::swap(head->flNext, res->flNext);
- jitstd::swap(head, res);
+ std::swap(head->flNext, res->flNext);
+ std::swap(head, res);
}
}
return head;
}
unsigned ssaNum = GetMinSsaNum() + m_count;
- m_array[m_count++] = T(jitstd::forward<Args>(args)...);
+ m_array[m_count++] = T(std::forward<Args>(args)...);
// Ensure that the first SSA number we allocate is SsaConfig::FIRST_SSA_NUM
assert((ssaNum == SsaConfig::FIRST_SSA_NUM) || (m_count > 1));
if (n == nullptr)
{
- n = new (m_alloc) Node(m_table[index], k, jitstd::forward<Args>(args)...);
+ n = new (m_alloc) Node(m_table[index], k, std::forward<Args>(args)...);
m_table[index] = n;
m_tableCount++;
Value m_val;
template <class... Args>
- Node(Node* next, Key k, Args&&... args) : m_next(next), m_key(k), m_val(jitstd::forward<Args>(args)...)
+ Node(Node* next, Key k, Args&&... args) : m_next(next), m_key(k), m_val(std::forward<Args>(args)...)
{
}
// See the LICENSE file in the project root for more information.
#include "allocator.h"
-#include "functional.h"
#include "list.h"
-#include "pair.h"
-#include "type_traits.h"
#include "utility.h"
#include "vector.h"
namespace jitstd
{
-template <typename InputIterator, typename CompareValue>
-InputIterator find(InputIterator first, InputIterator last,
- const CompareValue& value)
-{
- for (; first != last; ++first)
- {
- if (*first == value)
- {
- return first;
- }
- }
- return last;
-}
-
-template <typename InputIterator, typename Pred>
-InputIterator find_if(InputIterator first, InputIterator last, const Pred& pred)
-{
- for (; first != last; ++first)
- {
- if (pred(*first))
- {
- return first;
- }
- }
- return last;
-}
-
-template<typename InputIterator, typename Function>
-Function for_each(InputIterator first, InputIterator last, Function func)
-{
- for (; first != last; ++first)
- {
- func(*first);
- }
- return func;
-}
-
namespace
{
// Sort the elements in range [first, last] using insertion sort, an efficient alternative
// The usual median of 3 pivot, we'll have *first <= *pivot <= *last.
if (less(*pivot, *first))
{
- swap(*pivot, *first);
+ std::swap(*pivot, *first);
}
if (less(*last, *pivot))
{
- swap(*pivot, *last);
+ std::swap(*pivot, *last);
if (less(*pivot, *first))
{
- swap(*pivot, *first);
+ std::swap(*pivot, *first);
}
}
// We now have *newLast <= *pivot <= *newFirst so we need to swap
// *newFirst and *newLast.
- swap(*newFirst, *newLast);
+ std::swap(*newFirst, *newLast);
// pivot is an iterator and not the actual value, if the value gets
// swapped we need to update the iterator to point to the new place.
namespace jitstd
{
-template <typename T>
-void swap(T& a, T& b)
-{
- T t(a);
- a = b;
- b = t;
-}
-
-template <typename Arg, typename Result>
-struct unary_function
-{
- typedef Arg argument_type;
- typedef Result result_type;
-};
-
template <typename Arg1, typename Arg2, typename Result>
struct binary_function
{
}
};
-template <typename T>
-struct equal_to : binary_function<T, T, bool>
-{
- bool operator()(const T& lhs, const T& rhs) const
- {
- return lhs == rhs;
- }
-};
-
-template <typename T>
-struct identity : unary_function<T, T>
-{
- const T& operator()(const T& op) const
- {
- return op;
- }
-};
-
} // end of namespace jitstd.
#include "iterator.h"
#include "functional.h"
-#include "utility.h"
+#include "clr_std/utility"
namespace jitstd
{
template <class... Args>
Node(Args&&... args)
- : m_value(jitstd::forward<Args>(args)...)
+ : m_value(std::forward<Args>(args)...)
{
}
};
typename list<T, Allocator>::iterator
list<T, Allocator>::emplace(iterator position, Args&&... args)
{
- Node* pNewNode = new (m_nodeAllocator.allocate(1), placement_t()) Node(jitstd::forward<Args>(args)...);
+ Node* pNewNode = new (m_nodeAllocator.allocate(1), placement_t()) Node(std::forward<Args>(args)...);
insert_new_node_helper(position.m_pNode, pNewNode);
return iterator(pNewNode);
}
template <typename... Args>
void list<T, Allocator>::emplace_back(Args&&... args)
{
- emplace(end(), jitstd::forward<Args>(args)...);
+ emplace(end(), std::forward<Args>(args)...);
}
template <typename T, typename Allocator>
template <typename... Args>
void list<T, Allocator>::emplace_front(Args&&... args)
{
- emplace(begin(), jitstd::forward<Args>(args)...);
+ emplace(begin(), std::forward<Args>(args)...);
}
template <typename T, typename Allocator>
{
for (Node* p = m_pHead; p != NULL; p = p->m_pNext)
{
- jitstd::swap(p->m_pPrev, p->m_pNext);
+ std::swap(p->m_pPrev, p->m_pNext);
}
- jitstd::swap(m_pHead, m_pTail);
+ std::swap(m_pHead, m_pTail);
}
template <typename T, typename Allocator>
template <typename T, typename Allocator>
void list<T, Allocator>::swap(list<T, Allocator>& lst)
{
- jitstd::swap(lst.m_pHead, m_pHead);
- jitstd::swap(lst.m_pTail, m_pTail);
- jitstd::swap(lst.m_nSize, m_nSize);
- jitstd::swap(lst.m_allocator, m_allocator);
- jitstd::swap(lst.m_nodeAllocator, m_nodeAllocator);
+ std::swap(lst.m_pHead, m_pHead);
+ std::swap(lst.m_pTail, m_pTail);
+ std::swap(lst.m_nSize, m_nSize);
+ std::swap(lst.m_allocator, m_allocator);
+ std::swap(lst.m_nodeAllocator, m_nodeAllocator);
}
template <typename T, typename Allocator>
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-
-#pragma once
-
-namespace jitstd
-{
-template <typename Type1, typename Type2>
-class pair
-{
-public:
- Type1 first;
- Type2 second;
-
- pair(const Type1& fst, const Type2& sec)
- : first(fst)
- , second(sec)
- {
- }
-
- template <typename AltType1, typename AltType2>
- pair(const AltType1& fst, const AltType2& sec)
- : first((Type1) fst)
- , second((Type2) sec)
- {
- }
-
- template <typename AltType1, typename AltType2>
- pair(const pair<AltType1, AltType2>& that)
- : first((Type1) that.first)
- , second((Type2) that.second)
- {
- }
-
- pair(const pair& that)
- : first(that.first)
- , second(that.second)
- {
- }
-
- template <typename AltType1, typename AltType2>
- const pair<Type1, Type2>& operator=(const pair<AltType1, AltType2>& pair)
- {
- first = pair.first;
- second = pair.second;
- return *this;
- }
-
- bool operator==(const pair<Type1, Type2>& other) const
- {
- return (other.first == first && other.second == second);
- }
-};
-}
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-#pragma once
-
-namespace jitstd
-{
-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_volatile
-{
- typedef T type;
-};
-
-template <typename T>
-struct remove_volatile<volatile T>
-{
- typedef T type;
-};
-
-template <typename T>
-struct remove_cv : remove_const<typename remove_volatile<T>::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;
-};
-
-template <typename T>
-struct is_lvalue_reference
-{
- enum { value = false };
-};
-
-template <typename T>
-struct is_lvalue_reference<T&>
-{
- enum { value = true };
-};
-
-template <typename T>
-struct is_unqualified_pointer
-{
- enum { value = false };
-};
-
-template <typename T>
-struct is_unqualified_pointer<T*>
-{
- enum { value = true };
-};
-
-template <typename T>
-struct is_pointer : is_unqualified_pointer<typename remove_cv<T>::type>
-{
-};
-
-template <typename T>
-struct is_integral
-{
- enum { value = false };
-};
-
-template<>
-struct is_integral<bool>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<char>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<unsigned char>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<signed char>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<unsigned short>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<signed short>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<unsigned int>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<signed int>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<unsigned __int64>
-{
- enum { value = true };
-};
-
-template<>
-struct is_integral<signed __int64>
-{
- enum { value = true };
-};
-
-
-template<bool Pred, typename Type1, typename Type2>
-struct conditional
-{
-};
-
-template<typename Type1, typename Type2>
-struct conditional<true, Type1, Type2>
-{
- typedef Type1 type;
-};
-
-template<typename Type1, typename Type2>
-struct conditional<false, Type1, Type2>
-{
- typedef Type2 type;
-};
-
-template<typename Type1>
-struct make_unsigned
-{
-};
-
-template<>
-struct make_unsigned<int>
-{
- typedef unsigned int type;
-};
-
-#ifndef _HOST_UNIX_
-
-template<>
-struct make_unsigned<long>
-{
- typedef unsigned long type;
-};
-
-#endif // !_HOST_UNIX_
-
-template<>
-struct make_unsigned<__int64>
-{
- typedef unsigned __int64 type;
-};
-
-template<>
-struct make_unsigned<size_t>
-{
- typedef size_t type;
-};
-
-template<typename Type1>
-struct make_signed
-{
-};
-
-template<>
-struct make_signed<unsigned int>
-{
- typedef signed int type;
-};
-
-#ifndef _HOST_UNIX_
-
-template<>
-struct make_signed<unsigned long>
-{
- typedef signed long type;
-};
-
-#endif // !_HOST_UNIX_
-
-template<>
-struct make_signed<unsigned __int64>
-{
- typedef signed __int64 type;
-};
-
-} // namespace jitstd
#pragma once
-#include "pair.h"
-#include "type_traits.h"
+#include "clr_std/type_traits"
namespace jitstd
{
-template <typename T>
-inline
-T&& forward(typename jitstd::remove_reference<T>::type& arg)
-{
- return static_cast<T&&>(arg);
-}
-
-template <typename T>
-inline
-T&& forward(typename jitstd::remove_reference<T>::type&& arg)
-{
- static_assert(!jitstd::is_lvalue_reference<T>::value, "unexpected lvalue reference");
- return static_cast<T&&>(arg);
-}
-
namespace utility
{
// Template class for scoped execution of a lambda.
scoped_code(const T& l) : l(l) { }
~scoped_code() { l(); }
};
-
-
- // Ensures that "wset" is the union of the initial state of "wset" and "rset".
- // Elements from "rset" that were not in "wset" are added to "cset."
- template <typename Set>
- bool set_union(Set& wset, const Set& rset, Set& cset)
- {
- bool change = false;
- for (typename Set::const_iterator i = rset.begin(); i != rset.end(); ++i)
- {
- jitstd::pair<typename Set::iterator, bool> result = wset.insert(*i);
- if (result.second)
- {
- change = true;
- cset.insert(*i);
- }
- }
- return change;
- }
-
- template <typename Set>
- bool set_union(Set& wset, const Set& rset)
- {
- bool change = false;
- for (typename Set::const_iterator i = rset.begin(); i != rset.end(); ++i)
- {
- jitstd::pair<typename Set::iterator, bool> result = wset.insert(*i);
- change |= result.second;
- }
- return change;
- }
-
- template <typename Set>
- bool set_difference(Set& wset, const Set& rset)
- {
- bool change = false;
- for (typename Set::const_iterator i = rset.begin(); i != rset.end(); ++i)
- {
- if (wset.find(*i) != wset.end())
- {
- wset.erase(*i);
- change = true;
- }
- }
-
- return change;
- }
} // end of namespace utility.
} // end of namespace jitstd.
template <typename T, typename Allocator>
void vector<T, Allocator>::swap(vector<T, Allocator>& vec)
{
- jitstd::swap(m_pArray, vec.m_pArray);
- jitstd::swap(m_nSize, vec.m_nSize);
- jitstd::swap(m_nCapacity, vec.m_nCapacity);
- jitstd::swap(m_nCapacity, vec.m_nCapacity);
- jitstd::swap(m_allocator, vec.m_allocator);
+ std::swap(m_pArray, vec.m_pArray);
+ std::swap(m_nSize, vec.m_nSize);
+ std::swap(m_nCapacity, vec.m_nCapacity);
+ std::swap(m_nCapacity, vec.m_nCapacity);
+ std::swap(m_allocator, vec.m_allocator);
}
// =======================================================================================
// Check if we have a var + const.
if (op2->OperGet() == GT_LCL_VAR)
{
- jitstd::swap(op1, op2);
+ std::swap(op1, op2);
}
if (op1->OperGet() != GT_LCL_VAR)
{
typedef int LclVarNum;
// Pair of a local var name eg: V01 and Ssa number; eg: V01_01
-typedef jitstd::pair<LclVarNum, int> SsaVarName;
+typedef std::pair<LclVarNum, int> SsaVarName;
class SsaBuilder
{
stack = m_alloc.allocate<StackNode>(1);
}
- return new (stack, jitstd::placement_t()) StackNode(jitstd::forward<Args>(args)...);
+ return new (stack, jitstd::placement_t()) StackNode(std::forward<Args>(args)...);
}
// Push a SSA number onto a stack
return magic->magic;
}
- typedef typename jitstd::make_signed<T>::type ST;
+ typedef typename std::make_signed<T>::type ST;
const unsigned bits = sizeof(T) * 8;
const unsigned bitsMinus1 = bits - 1;
const int bits = sizeof(T) * 8;
const int bits_minus_1 = bits - 1;
- typedef typename jitstd::make_unsigned<T>::type UT;
+ typedef typename std::make_unsigned<T>::type UT;
const UT two_nminus1 = UT(1) << bits_minus_1;
template <typename T>
T ValueNumStore::EvalOpSpecialized(VNFunc vnf, T v0, T v1)
{
- typedef typename jitstd::make_unsigned<T>::type UT;
+ typedef typename std::make_unsigned<T>::type UT;
assert((sizeof(T) == 4) || (sizeof(T) == 8));
template <typename T>
int ValueNumStore::EvalComparison(VNFunc vnf, T v0, T v1)
{
- typedef typename jitstd::make_unsigned<T>::type UT;
+ typedef typename std::make_unsigned<T>::type UT;
// Here we handle the compare ops that are the same for all integer types.
if (vnf < VNF_Boundary)
// Order arg0 arg1 by numerical VN value.
if (arg0VN > arg1VN)
{
- jitstd::swap(arg0VN, arg1VN);
+ std::swap(arg0VN, arg1VN);
}
}