1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // duckdb/common/helper.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/constants.hpp" |
12 | |
13 | #include <algorithm> |
14 | #include <limits> |
15 | #include <sstream> |
16 | |
17 | #ifdef _MSC_VER |
18 | #define suint64_t int64_t |
19 | #endif |
20 | |
21 | namespace duckdb { |
22 | #if !defined(_MSC_VER) && (__cplusplus < 201402L) |
23 | template <typename T, typename... Args> unique_ptr<T> make_unique(Args &&... args) { |
24 | return unique_ptr<T>(new T(std::forward<Args>(args)...)); |
25 | } |
26 | #else // Visual Studio has make_unique |
27 | using std::make_unique; |
28 | #endif |
29 | template <typename S, typename T, typename... Args> unique_ptr<S> make_unique_base(Args &&... args) { |
30 | return unique_ptr<S>(new T(std::forward<Args>(args)...)); |
31 | } |
32 | |
33 | template <class T> inline bool in_bounds(int64_t value) { |
34 | return value >= std::numeric_limits<T>::min() && value <= std::numeric_limits<T>::max(); |
35 | } |
36 | |
37 | template <typename T, typename S> unique_ptr<S> unique_ptr_cast(unique_ptr<T> src) { |
38 | return unique_ptr<S>(static_cast<S *>(src.release())); |
39 | } |
40 | |
41 | } // namespace duckdb |
42 | |