1 | /**************************************************************************** |
2 | * Copyright (C) 2012-2016 Woboq GmbH |
3 | * Olivier Goffart <contact at woboq.com> |
4 | * https://woboq.com/codebrowser.html |
5 | * |
6 | * This file is part of the Woboq Code Browser. |
7 | * |
8 | * Commercial License Usage: |
9 | * Licensees holding valid commercial licenses provided by Woboq may use |
10 | * this file in accordance with the terms contained in a written agreement |
11 | * between the licensee and Woboq. |
12 | * For further information see https://woboq.com/codebrowser.html |
13 | * |
14 | * Alternatively, this work may be used under a Creative Commons |
15 | * Attribution-NonCommercial-ShareAlike 3.0 (CC-BY-NC-SA 3.0) License. |
16 | * http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US |
17 | * This license does not allow you to use the code browser to assist the |
18 | * development of your commercial software. If you intent to do so, consider |
19 | * purchasing a commercial licence. |
20 | ****************************************************************************/ |
21 | |
22 | #pragma once |
23 | |
24 | #include <memory> |
25 | |
26 | // clang 3.6 uses unique_ptr in many places that was not using it before |
27 | template<typename T> struct MaybeUnique { |
28 | T *val; |
29 | operator T*() { return val; } |
30 | template <typename X> operator std::unique_ptr<X> () && { return std::unique_ptr<X>(val); } |
31 | }; |
32 | template<typename T> MaybeUnique<T> maybe_unique(T* val) { return {val}; } |
33 | |
34 | #ifndef LLVM_FALLTHROUGH |
35 | #define LLVM_FALLTHROUGH |
36 | #endif |
37 | |
38 | |