Mark namespaces for user defined literals as 'inline'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@192047 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1d927e38d1
commit
8d9dd7a968
@ -942,12 +942,9 @@ typedef steady_clock high_resolution_clock;
|
|||||||
|
|
||||||
} // chrono
|
} // chrono
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
// Literal suffixes for chrono types
|
// Suffixes for duration literals [time.duration.literals]
|
||||||
// inline // Deviation from N3690.
|
inline namespace literals
|
||||||
// We believe the inline to be a defect and have submitted an LWG issue.
|
|
||||||
// An LWG issue number has not yet been assigned.
|
|
||||||
namespace literals
|
|
||||||
{
|
{
|
||||||
inline namespace chrono_literals
|
inline namespace chrono_literals
|
||||||
{
|
{
|
||||||
@ -1018,6 +1015,11 @@ namespace literals
|
|||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
namespace chrono { // hoist the literals into namespace std::chrono
|
||||||
|
using namespace literals::chrono_literals;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_LIBCPP_END_NAMESPACE_STD
|
_LIBCPP_END_NAMESPACE_STD
|
||||||
|
@ -4158,10 +4158,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
// Literal suffixes for basic_string [basic.string.literals]
|
// Literal suffixes for basic_string [basic.string.literals]
|
||||||
// inline // Deviation from N3690.
|
inline namespace literals
|
||||||
// We believe the inline to be a defect and have submitted an LWG issue.
|
|
||||||
// An LWG issue number has not yet been assigned.
|
|
||||||
namespace literals
|
|
||||||
{
|
{
|
||||||
inline namespace string_literals
|
inline namespace string_literals
|
||||||
{
|
{
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
using namespace std;
|
using std::string;
|
||||||
|
|
||||||
std::string foo = ""s; // should fail w/conversion operator not found
|
string foo = ""s; // should fail w/conversion operator not found
|
||||||
#else
|
#else
|
||||||
#error
|
#error
|
||||||
#endif
|
#endif
|
||||||
|
20
test/strings/basic.string.literals/literal3.pass.cpp
Normal file
20
test/strings/basic.string.literals/literal3.pass.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
#include <string>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string foo = ""s;
|
||||||
|
#endif
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
#include <chrono>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
std::chrono::hours h = 4h; // should fail w/conversion operator not found
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
#include <chrono>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
hours h = 4h;
|
||||||
|
assert ( h == hours(4));
|
||||||
|
auto h2 = 4.0h;
|
||||||
|
assert ( h == h2 );
|
||||||
|
|
||||||
|
minutes min = 36min;
|
||||||
|
assert ( min == minutes(36));
|
||||||
|
auto min2 = 36.0min;
|
||||||
|
assert ( min == min2 );
|
||||||
|
|
||||||
|
seconds s = 24s;
|
||||||
|
assert ( s == seconds(24));
|
||||||
|
auto s2 = 24.0s;
|
||||||
|
assert ( s == s2 );
|
||||||
|
|
||||||
|
milliseconds ms = 247ms;
|
||||||
|
assert ( ms == milliseconds(247));
|
||||||
|
auto ms2 = 247.0ms;
|
||||||
|
assert ( ms == ms2 );
|
||||||
|
|
||||||
|
microseconds us = 867us;
|
||||||
|
assert ( us == microseconds(867));
|
||||||
|
auto us2 = 867.0us;
|
||||||
|
assert ( us == us2 );
|
||||||
|
|
||||||
|
nanoseconds ns = 645ns;
|
||||||
|
assert ( ns == nanoseconds(645));
|
||||||
|
auto ns2 = 645.ns;
|
||||||
|
assert ( ns == ns2 );
|
||||||
|
#endif
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
#include <chrono>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
using std::chrono::hours;
|
||||||
|
|
||||||
|
hours foo = 4h; // should fail w/conversion operator not found
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// <chrono>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
using namespace std::literals;
|
||||||
|
|
||||||
|
std::chrono::hours h = 4h;
|
||||||
|
assert ( h == std::chrono::hours(4));
|
||||||
|
auto h2 = 4.0h;
|
||||||
|
assert ( h == h2 );
|
||||||
|
|
||||||
|
std::chrono::minutes min = 36min;
|
||||||
|
assert ( min == std::chrono::minutes(36));
|
||||||
|
auto min2 = 36.0min;
|
||||||
|
assert ( min == min2 );
|
||||||
|
|
||||||
|
std::chrono::seconds s = 24s;
|
||||||
|
assert ( s == std::chrono::seconds(24));
|
||||||
|
auto s2 = 24.0s;
|
||||||
|
assert ( s == s2 );
|
||||||
|
|
||||||
|
std::chrono::milliseconds ms = 247ms;
|
||||||
|
assert ( ms == std::chrono::milliseconds(247));
|
||||||
|
auto ms2 = 247.0ms;
|
||||||
|
assert ( ms == ms2 );
|
||||||
|
|
||||||
|
std::chrono::microseconds us = 867us;
|
||||||
|
assert ( us == std::chrono::microseconds(867));
|
||||||
|
auto us2 = 867.0us;
|
||||||
|
assert ( us == us2 );
|
||||||
|
|
||||||
|
std::chrono::nanoseconds ns = 645ns;
|
||||||
|
assert ( ns == std::chrono::nanoseconds(645));
|
||||||
|
auto ns2 = 645.ns;
|
||||||
|
assert ( ns == ns2 );
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user