Implement variadic lock_guard.
Summary: This patch implements the variadic `lock_guard` paper. Making `lock_guard` variadic is a ABI breaking change because the specialization `lock_guard<_Mutex>` mangles differently then when it was the primary template. This change only provides variadic `lock_guard` in ABI V2 or when `_LIBCPP_ABI_VARIADIC_LOCK_GUARD` is defined. Note that in ABI V2 `lock_guard` must always be declared as a variadic template, even in C++03, in order to keep the ABI consistent. For this reason `lock_guard` is forward declared as a variadic template in all standard dialects and therefore depends on variadic templates being provided as an extension in C++03. All supported versions of Clang and GCC provide this extension. Reviewers: mclow.lists Subscribers: K-ballo, mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D21260 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272634 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: libcpp-has-no-threads
|
||||
|
||||
// THIS TESTS C++03 EXTENSIONS.
|
||||
|
||||
// <mutex>
|
||||
|
||||
// template <class ...Mutex> class lock_guard;
|
||||
|
||||
// Test that the the variadic lock guard implementation mangles the same in
|
||||
// C++11 and C++03. This is important since the mangling of `lock_guard` depends
|
||||
// on it being declared as a variadic template, even in C++03.
|
||||
|
||||
#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
|
||||
#include <mutex>
|
||||
#include <typeinfo>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
const std::string expect = "NSt3__110lock_guardIJNS_5mutexEEEE";
|
||||
assert(typeid(std::lock_guard<std::mutex>).name() == expect);
|
||||
}
|
||||
Reference in New Issue
Block a user