File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -71,20 +71,20 @@ namespace cpp2 {
71
71
//
72
72
struct {
73
73
template <typename T, typename ... Args>
74
- [[nodiscard]] auto new_ (auto ...args) const -> std::unique_ptr<T> {
74
+ [[nodiscard]] auto cpp2_new (auto ...args) const -> std::unique_ptr<T> {
75
75
return std::make_unique<T>(CPP2_FORWARD (args)...);
76
76
}
77
77
} unique;
78
78
79
79
struct {
80
80
template <typename T, typename ... Args>
81
- [[nodiscard]] auto new_ (auto ...args) const -> std::unique_ptr <T> {
81
+ [[nodiscard]] auto cpp2_new (auto ...args) const -> std::shared_ptr <T> {
82
82
return std::make_shared<T>(CPP2_FORWARD (args)...);
83
83
}
84
84
} shared;
85
85
86
86
template <typename T, typename ... Args>
87
- [[nodiscard]] auto new_ (auto ...args) -> std::unique_ptr<T> {
87
+ [[nodiscard]] auto cpp2_new (auto ...args) -> std::unique_ptr<T> {
88
88
return std::make_unique<T>(CPP2_FORWARD (args)...);
89
89
}
90
90
@@ -389,7 +389,9 @@ int main() {
389
389
390
390
*/
391
391
392
-
393
392
}
394
393
394
+ using cpp2::cpp2_new;
395
+
396
+
395
397
#endif
Original file line number Diff line number Diff line change @@ -826,7 +826,7 @@ class cppfront
826
826
auto emit (token const & n) -> void
827
827
{
828
828
if (n == " new" ) {
829
- printer.print_cpp2 (" new_ " , n.position ());
829
+ printer.print_cpp2 (" cpp2_new " , n.position ());
830
830
}
831
831
else {
832
832
printer.print_cpp2 (n, n.position ());
@@ -893,6 +893,16 @@ class cppfront
893
893
//
894
894
auto emit (qualified_id_node const & n) -> void
895
895
{
896
+ // Implicit "cpp2::" qualification of "unique.new" and "shared.new"
897
+ if (n.ids .size () == 2 &&
898
+ (*n.ids [0 ].id ->identifier == " unique" || *n.ids [0 ].id ->identifier == " shared" ) &&
899
+ *n.ids [1 ].scope_op == " ." &&
900
+ *n.ids [1 ].id ->identifier == " new"
901
+ )
902
+ {
903
+ printer.print_cpp2 (" cpp2::" , n.position ());
904
+ }
905
+
896
906
auto ident = std::string{};
897
907
printer.emit_to_string (&ident);
898
908
You can’t perform that action at this time.
0 commit comments