|
| 1 | +#ifndef SHIMS_POST_HPP_8044E77C_AF33_4C40_8C9A_59C722E54280 |
| 2 | +#define SHIMS_POST_HPP_8044E77C_AF33_4C40_8C9A_59C722E54280 |
| 3 | +#pragma once |
| 4 | + |
| 5 | +/* |
| 6 | +shims_post.hpp |
| 7 | +
|
| 8 | +Workarounds for supported compilers & libraries |
| 9 | +
|
| 10 | +Here be dragons |
| 11 | +*/ |
| 12 | +/* |
| 13 | +Copyright © 2025 Far Group |
| 14 | +All rights reserved. |
| 15 | +
|
| 16 | +Redistribution and use in source and binary forms, with or without |
| 17 | +modification, are permitted provided that the following conditions |
| 18 | +are met: |
| 19 | +1. Redistributions of source code must retain the above copyright |
| 20 | + notice, this list of conditions and the following disclaimer. |
| 21 | +2. Redistributions in binary form must reproduce the above copyright |
| 22 | + notice, this list of conditions and the following disclaimer in the |
| 23 | + documentation and/or other materials provided with the distribution. |
| 24 | +3. The name of the authors may not be used to endorse or promote products |
| 25 | + derived from this software without specific prior written permission. |
| 26 | +
|
| 27 | +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 28 | +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 29 | +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 30 | +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 31 | +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 32 | +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 33 | +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 34 | +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 35 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 36 | +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 37 | +*/ |
| 38 | + |
| 39 | +#include "compiler.hpp" |
| 40 | + |
| 41 | +#include <version> |
| 42 | + |
| 43 | +//---------------------------------------------------------------------------- |
| 44 | + |
| 45 | +#if COMPILER(CL) |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +#endif |
| 50 | + |
| 51 | +//---------------------------------------------------------------------------- |
| 52 | + |
| 53 | +#if COMPILER(GCC) |
| 54 | + |
| 55 | +// These inline implementations in gcc/cwchar are wrong and non-compilable if _CONST_RETURN is defined. |
| 56 | +namespace std |
| 57 | +{ |
| 58 | + inline wchar_t* wcschr(wchar_t* p, wchar_t c) |
| 59 | + { |
| 60 | + return const_cast<wchar_t*>(wcschr(const_cast<const wchar_t*>(p), c)); |
| 61 | + } |
| 62 | + |
| 63 | + inline wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2) |
| 64 | + { |
| 65 | + return const_cast<wchar_t*>(wcspbrk(const_cast<const wchar_t*>(s1), s2)); |
| 66 | + } |
| 67 | + |
| 68 | + inline wchar_t* wcsrchr(wchar_t* p, wchar_t c) |
| 69 | + { |
| 70 | + return const_cast<wchar_t*>(wcsrchr(const_cast<const wchar_t*>(p), c)); |
| 71 | + } |
| 72 | + |
| 73 | + inline wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2) |
| 74 | + { |
| 75 | + return const_cast<wchar_t*>(wcsstr(const_cast<const wchar_t*>(s1), s2)); |
| 76 | + } |
| 77 | + |
| 78 | + inline wchar_t* wmemchr(wchar_t* p, wchar_t c, size_t n) |
| 79 | + { |
| 80 | + return const_cast<wchar_t*>(wmemchr(const_cast<const wchar_t*>(p), c, n)); |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +using std::wcschr; |
| 85 | +using std::wcspbrk; |
| 86 | +using std::wcsrchr; |
| 87 | +using std::wcsstr; |
| 88 | +using std::wmemchr; |
| 89 | + |
| 90 | +#endif |
| 91 | + |
| 92 | +//---------------------------------------------------------------------------- |
| 93 | + |
| 94 | +#if COMPILER(CLANG) |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +#endif |
| 99 | + |
| 100 | +//---------------------------------------------------------------------------- |
| 101 | + |
| 102 | +#endif // SHIMS_POST_HPP_8044E77C_AF33_4C40_8C9A_59C722E54280 |
0 commit comments