You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had been using the Cpp1 syntax since I had nothing substantially better. But that did leave the grammar divergence between
using std::vector; // use one thing from std
using namespace std; // use everything in std
But then I remembered the `_` wildcard, so with this change instead of `using namespace NNN ;` we write `using NNN::_ ;`. This makes them more consistent:
using std::vector ; // use one thing from std
using std::_ ; // use everything in std
Of course the latter still lowers to Cpp1 `using namespace std;`
Copy file name to clipboardExpand all lines: docs/cpp2/namespaces.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,11 +20,11 @@ main: () = {
20
20
21
21
## <aid="using"></a> `using`
22
22
23
-
A `#!cpp using` statement brings names declared in another namespace into the current scope as if they had been declared in the current scope. It has two forms:
23
+
A `#!cpp using` statement brings names declared in another namespace into the current scope as if they had been declared in the current scope.
24
24
25
-
-`#!cpp using a_namespace::a_name;` brings the single name `a_name` into scope.
25
+
`#!cpp using a_namespace::a_name;` brings the single name `a_name` into scope.
26
26
27
-
-`#!cpp using namespace a_namespace;` brings all the namespace's names into scope.
27
+
`#!cpp using a_namespace::_ ;` brings all the namespace's names into scope using the `#!cpp _` wildcard.
28
28
29
29
For example:
30
30
@@ -40,15 +40,15 @@ main: () = {
40
40
w: widgetlib::widget = /*...*/;
41
41
42
42
{
43
-
// Using the name, no qualification needed
43
+
// Using the specific name, no widgetlib:: qualification needed
44
44
using widgetlib::widget;
45
45
w2: widget = /*...*/;
46
46
// ...
47
47
}
48
48
49
49
{
50
-
// Using the whole namespace, no qualification needed
51
-
using namespace widgetlib;
50
+
// Using the whole namespace, no widgetlib:: qualification needed
Copy file name to clipboardExpand all lines: regression-tests/test-results/msvc-2022-c++latest/pure2-type-safety-1.cpp.output
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
pure2-type-safety-1.cpp
2
2
pure2-type-safety-1.cpp2(26): error C2666: 'print': overloaded functions have similar conversions
3
3
pure2-type-safety-1.cpp2(29): note: could be 'void print(const std::string &,const bool)'
4
-
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\include\print(125): note: or 'void std::print<std::false_type>(const std::basic_format_string<char,std::integral_constant<bool,false>>,std::false_type &&)' [found using argument-dependent lookup]
4
+
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\print(125): note: or 'void std::print<std::false_type>(const std::basic_format_string<char,std::integral_constant<bool,false>>,std::false_type &&)' [found using argument-dependent lookup]
5
5
pure2-type-safety-1.cpp2(26): note: while trying to match the argument list '(std::basic_string<char,std::char_traits<char>,std::allocator<char>>, std::false_type)'
6
6
pure2-type-safety-1.cpp2(26): note: the template instantiation context (the oldest one first) is
7
7
pure2-type-safety-1.cpp2(8): note: see reference to function template instantiation 'void test_generic<double,char[7]>(const _T0 &,const _T1 (&))' being compiled
0 commit comments