Skip to content

Commit

Permalink
Merge pull request #21 from microsoft/master
Browse files Browse the repository at this point in the history
Update __cpp_lib_concepts (see WG21-P1902). (microsoft#287)
  • Loading branch information
fengjixuchui authored Nov 12, 2019
2 parents 9370d05 + bfb96b1 commit 1d39f9f
Show file tree
Hide file tree
Showing 41 changed files with 499 additions and 256 deletions.
23 changes: 15 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# https://releases.llvm.org/7.0.0/tools/clang/docs/ClangFormatStyleOptions.html
# https://releases.llvm.org/9.0.0/tools/clang/docs/ClangFormatStyleOptions.html

---
# Language: Cpp
Expand All @@ -14,6 +14,9 @@ AccessModifierOffset: -4
# AlignAfterOpenBracket: Align
AlignAfterOpenBracket: DontAlign

# AlignConsecutiveMacros: false
AlignConsecutiveMacros: true

# AlignConsecutiveAssignments: false
AlignConsecutiveAssignments: true

Expand All @@ -27,29 +30,29 @@ AlignEscapedNewlines: Left
# AlignTrailingComments: true
AlignTrailingComments: false

# AllowAllArgumentsOnNextLine: true
# AllowAllConstructorInitializersOnNextLine: true
# AllowAllParametersOfDeclarationOnNextLine: true
# AllowShortBlocksOnASingleLine: false
# AllowShortCaseLabelsOnASingleLine: false

# AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: Empty

# AllowShortIfStatementsOnASingleLine: false
# AllowShortLambdasOnASingleLine: All
# AllowShortIfStatementsOnASingleLine: Never
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false

# Clang 7 default:
# AlwaysBreakTemplateDeclarations: MultiLine
# Clang 7 customization:
# AlwaysBreakTemplateDeclarations: Yes
# Clang 6 compatible customization:
AlwaysBreakTemplateDeclarations: true
AlwaysBreakTemplateDeclarations: Yes

# BinPackArguments: true
# BinPackParameters: true
# BraceWrapping:
# AfterCaseLabel: false
# AfterClass: false
# AfterControlStatement: false
# AfterEnum: false
Expand Down Expand Up @@ -91,7 +94,7 @@ ColumnLimit: 120
# DisableFormat: false
# ExperimentalAutoDetectBinPacking: false

# NOTE: LLVM-39247, this emits damaged "// namespace _DEPRECATE_TR1_NAMESPACEtr1".
# TRANSITION, LLVM-39247, fixed in clang-format 10.
# FixNamespaceComments: true
FixNamespaceComments: false

Expand Down Expand Up @@ -167,6 +170,7 @@ PointerAlignment: Left
# SpaceAfterCStyleCast: false
SpaceAfterCStyleCast: true

# SpaceAfterLogicalNot: false
# SpaceAfterTemplateKeyword: true
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCpp11BracedList: false
Expand All @@ -182,6 +186,9 @@ SpaceAfterCStyleCast: true
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# Standard: Cpp11
# StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
# TabWidth: 8
# UseTab: Never
...
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
{
"editor.formatOnSave": true,
"files.associations": {
"**/stl/inc/**": "cpp"
},
"files.eol": "\r\n",
"files.exclude": {
"stl/msbuild": true,
"vcpkg": true
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
}
1 change: 1 addition & 0 deletions stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/memory_resource
${CMAKE_CURRENT_LIST_DIR}/inc/mutex
${CMAKE_CURRENT_LIST_DIR}/inc/new
${CMAKE_CURRENT_LIST_DIR}/inc/numbers
${CMAKE_CURRENT_LIST_DIR}/inc/numeric
${CMAKE_CURRENT_LIST_DIR}/inc/optional
${CMAKE_CURRENT_LIST_DIR}/inc/ostream
Expand Down
1 change: 1 addition & 0 deletions stl/inc/__msvc_all_public_headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include <memory>
#include <memory_resource>
#include <new>
#include <numbers>
#include <numeric>
#include <optional>
#include <ostream>
Expand Down
26 changes: 13 additions & 13 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ _STL_DISABLE_CLANG_WARNINGS
#define _Compiler_barrier() _STL_DISABLE_DEPRECATED_WARNING _ReadWriteBarrier() _STL_RESTORE_DEPRECATED_WARNING

#if defined(_M_ARM) || defined(_M_ARM64)
#define _Memory_barrier() __dmb(0xB) // inner shared data memory barrier
#define _Memory_barrier() __dmb(0xB) // inner shared data memory barrier
#define _Compiler_or_memory_barrier() _Memory_barrier()

#define _ISO_VOLATILE_STORE8(_Storage, _Value) __iso_volatile_store8(_Atomic_address_as<char>(_Storage), _Value)
#define _ISO_VOLATILE_STORE8(_Storage, _Value) __iso_volatile_store8(_Atomic_address_as<char>(_Storage), _Value)
#define _ISO_VOLATILE_STORE16(_Storage, _Value) __iso_volatile_store16(_Atomic_address_as<short>(_Storage), _Value)
#define _ISO_VOLATILE_STORE32(_Storage, _Value) __iso_volatile_store32(_Atomic_address_as<int>(_Storage), _Value)
#define _ISO_VOLATILE_STORE64(_Storage, _Value) __iso_volatile_store64(_Atomic_address_as<long long>(_Storage), _Value)
#define _ISO_VOLATILE_LOAD8(_Storage) __iso_volatile_load8(_Atomic_address_as<const char>(_Storage))
#define _ISO_VOLATILE_LOAD16(_Storage) __iso_volatile_load16(_Atomic_address_as<const short>(_Storage))
#define _ISO_VOLATILE_LOAD8(_Storage) __iso_volatile_load8(_Atomic_address_as<const char>(_Storage))
#define _ISO_VOLATILE_LOAD16(_Storage) __iso_volatile_load16(_Atomic_address_as<const short>(_Storage))

#elif defined(_M_IX86) || defined(_M_X64)
// x86/x64 hardware only emits memory barriers inside _Interlocked intrinsics
#define _Compiler_or_memory_barrier() _Compiler_barrier()

#define _ISO_VOLATILE_STORE8(_Storage, _Value) (*_Atomic_address_as<char>(_Storage) = _Value)
#define _ISO_VOLATILE_STORE8(_Storage, _Value) (*_Atomic_address_as<char>(_Storage) = _Value)
#define _ISO_VOLATILE_STORE16(_Storage, _Value) (*_Atomic_address_as<short>(_Storage) = _Value)
#define _ISO_VOLATILE_STORE32(_Storage, _Value) (*_Atomic_address_as<long>(_Storage) = _Value)
#define _ISO_VOLATILE_STORE64(_Storage, _Value) (*_Atomic_address_as<long long>(_Storage) = _Value)
#define _ISO_VOLATILE_LOAD8(_Storage) (*_Atomic_address_as<const char>(_Storage))
#define _ISO_VOLATILE_LOAD16(_Storage) (*_Atomic_address_as<const short>(_Storage))
#define _ISO_VOLATILE_LOAD8(_Storage) (*_Atomic_address_as<const char>(_Storage))
#define _ISO_VOLATILE_LOAD16(_Storage) (*_Atomic_address_as<const short>(_Storage))

#else // ^^^ x86/x64 / unsupported hardware vvv
#error Unsupported hardware
Expand Down Expand Up @@ -124,12 +124,12 @@ _NODISCARD extern "C" bool __cdecl __std_atomic_has_cmpxchg16b() noexcept;
#endif // __cpp_lib_char8_t
#define ATOMIC_CHAR16_T_LOCK_FREE 2
#define ATOMIC_CHAR32_T_LOCK_FREE 2
#define ATOMIC_WCHAR_T_LOCK_FREE 2
#define ATOMIC_SHORT_LOCK_FREE 2
#define ATOMIC_INT_LOCK_FREE 2
#define ATOMIC_LONG_LOCK_FREE 2
#define ATOMIC_LLONG_LOCK_FREE 2
#define ATOMIC_POINTER_LOCK_FREE 2
#define ATOMIC_WCHAR_T_LOCK_FREE 2
#define ATOMIC_SHORT_LOCK_FREE 2
#define ATOMIC_INT_LOCK_FREE 2
#define ATOMIC_LONG_LOCK_FREE 2
#define ATOMIC_LLONG_LOCK_FREE 2
#define ATOMIC_POINTER_LOCK_FREE 2

_STD_BEGIN

Expand Down
4 changes: 2 additions & 2 deletions stl/inc/codecvt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma warning(disable : 4127) // conditional expression is constant

_STD_BEGIN
#define _LITTLE_FIRST 1
#define _BIG_FIRST 2
#define _LITTLE_FIRST 1
#define _BIG_FIRST 2
#define _BYTES_PER_WORD 4

enum _CXX17_DEPRECATE_CODECVT_HEADER codecvt_mode { consume_header = 4, generate_header = 2, little_endian = 1 };
Expand Down
4 changes: 4 additions & 0 deletions stl/inc/concepts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ concept signed_integral = integral<_Ty> && _Ty(-1) < _Ty(0);
template <class _Ty>
concept unsigned_integral = integral<_Ty> && !signed_integral<_Ty>;

// CONCEPT floating_point
template <class _Ty>
concept floating_point = is_floating_point_v<_Ty>;

// CONCEPT assignable_from
template <class _LTy, class _RTy>
concept assignable_from = is_lvalue_reference_v<_LTy>
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/experimental/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ You can define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to acknowled
_FS_BEGIN
using _Pchar = wchar_t; // UTF16
#define _FS_ISSEP(x) ((x) == L'/' || (x) == L'\\')
#define _FS_PREF L'\\'
#define _FS_PREF L'\\'

#define _FS_COLON L':'
#define _FS_COLON L':'
#define _FS_PERIOD L'.'
#define _FS_SLASH L'/'
#define _FS_SLASH L'/'
#define _FS_BSLASH L'\\'


Expand Down
4 changes: 2 additions & 2 deletions stl/inc/iosfwd
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ _STD_BEGIN
_CATCH_END

#else // _HAS_EXCEPTIONS
#define _TRY_IO_BEGIN { // begin try block
#define _CATCH_IO_END } // catch block for _Myios
#define _TRY_IO_BEGIN { // begin try block
#define _CATCH_IO_END } // catch block for _Myios
#define _CATCH_IO_(xtype, x) } // catch block for basic_ios x
#endif // _HAS_EXCEPTIONS

Expand Down
17 changes: 12 additions & 5 deletions stl/inc/iterator
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,23 @@ public:
using traits_type = _Traits;
using istream_type = basic_istream<_Elem, _Traits>;

constexpr istream_iterator() : _Myistr(nullptr), _Myval() {}
static_assert(conjunction_v<is_default_constructible<_Ty>, is_copy_constructible<_Ty>, is_copy_assignable<_Ty>>,
"istream_iterator<T> requires T to be default constructible, copy constructible, and copy assignable. "
"(N4835 [istream.iterator]/2)");

constexpr istream_iterator() {}

istream_iterator(istream_type& _Istr) : _Myistr(_STD addressof(_Istr)) {
_Getval();
}

_NODISCARD const _Ty& operator*() const {
_STL_ASSERT(_Myistr, "The stored stream pointer in_stream must be non-null");
return _Myval;
}

_NODISCARD const _Ty* operator->() const {
_STL_ASSERT(_Myistr, "The stored stream pointer in_stream must be non-null");
return _STD addressof(_Myval);
}

Expand All @@ -162,15 +168,16 @@ public:
return _Myistr == _Right._Myistr;
}

protected:
private:
void _Getval() { // get a _Ty value if possible
if (_Myistr && !(*_Myistr >> _Myval)) {
_STL_ASSERT(_Myistr, "The stored stream pointer in_stream must be non-null");
if (!(*_Myistr >> _Myval)) {
_Myistr = nullptr;
}
}

istream_type* _Myistr; // pointer to input stream
_Ty _Myval; // lookahead value (valid if _Myistr is not null)
istream_type* _Myistr{nullptr}; // pointer to input stream
_Ty _Myval{}; // lookahead value (valid if _Myistr is not null)
};

template <class _Ty, class _Elem, class _Traits, class _Diff>
Expand Down
Loading

0 comments on commit 1d39f9f

Please sign in to comment.