mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Replaced include/swift/Basic/Algorithm.h with calls to standard algorithms
LLVM now requires C++14, and the header says the algorithms are backported from C++14.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
//===--- Algorithm.h - ------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines helper algorithms, some of which are ported from C++14,
|
||||
// which may not be available on all platforms yet.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SWIFT_BASIC_ALGORITHM_H
|
||||
#define SWIFT_BASIC_ALGORITHM_H
|
||||
|
||||
namespace swift {
|
||||
/// Returns the minimum of `a` and `b`, or `a` if they are equivalent.
|
||||
template <typename T>
|
||||
constexpr const T &min(const T &a, const T &b) {
|
||||
return !(b < a) ? a : b;
|
||||
}
|
||||
|
||||
/// Returns the maximum of `a` and `b`, or `a` if they are equivalent.
|
||||
template <typename T>
|
||||
constexpr const T &max(const T &a, const T &b) {
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
} // end namespace swift
|
||||
|
||||
#endif // SWIFT_BASIC_ALGORITHM_H
|
||||
@@ -17,13 +17,12 @@
|
||||
#ifndef SWIFT_BASIC_FLAGGEDPOINTER_H
|
||||
#define SWIFT_BASIC_FLAGGEDPOINTER_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/PointerLikeTypeTraits.h"
|
||||
|
||||
#include "Algorithm.h"
|
||||
|
||||
namespace swift {
|
||||
|
||||
/// This class implements a pair of a pointer and boolean flag.
|
||||
@@ -170,7 +169,7 @@ public:
|
||||
enum {
|
||||
NumLowBitsAvailable = (BitPosition >= PtrTraits::NumLowBitsAvailable)
|
||||
? PtrTraits::NumLowBitsAvailable
|
||||
: (swift::min(int(BitPosition + 1),
|
||||
: (std::min(int(BitPosition + 1),
|
||||
int(PtrTraits::NumLowBitsAvailable)) - 1)
|
||||
};
|
||||
};
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#ifndef SWIFT_BASIC_PREFIXMAP_H
|
||||
#define SWIFT_BASIC_PREFIXMAP_H
|
||||
|
||||
#include "swift/Basic/Algorithm.h"
|
||||
#include "swift/Basic/Debug.h"
|
||||
#include "swift/Basic/LLVM.h"
|
||||
#include "swift/Basic/type_traits.h"
|
||||
@@ -53,8 +52,8 @@ template <class KeyElementType> class PrefixMapKeyPrinter;
|
||||
/// A map whose keys are sequences of comparable values, optimized for
|
||||
/// finding a mapped value for the longest matching initial subsequence.
|
||||
template <class KeyElementType, class ValueType,
|
||||
size_t InlineKeyCapacity
|
||||
= max<size_t>((sizeof(void*) - 1) / sizeof(KeyElementType), 1)>
|
||||
size_t InlineKeyCapacity = std::max(
|
||||
(sizeof(void *) - 1) / sizeof(KeyElementType), size_t(1))>
|
||||
class PrefixMap {
|
||||
public:
|
||||
using KeyType = ArrayRef<KeyElementType>;
|
||||
|
||||
Reference in New Issue
Block a user