Mark namespaces for user defined literals as 'inline'

llvm-svn: 192047
This commit is contained in:
Marshall Clow 2013-10-05 21:18:32 +00:00
parent c81e29435a
commit 3ceafc7f01
8 changed files with 173 additions and 12 deletions

View File

@ -943,11 +943,8 @@ typedef steady_clock high_resolution_clock;
} // chrono
#if _LIBCPP_STD_VER > 11
// Literal suffixes for chrono types
// inline // Deviation from N3690.
// 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
// Suffixes for duration literals [time.duration.literals]
inline namespace 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
_LIBCPP_END_NAMESPACE_STD

View File

@ -4158,10 +4158,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
#if _LIBCPP_STD_VER > 11
// Literal suffixes for basic_string [basic.string.literals]
// inline // Deviation from N3690.
// 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 literals
{
inline namespace string_literals
{

View File

@ -13,9 +13,9 @@
int main()
{
#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
#error
#endif

View 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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}