mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 06:13:02 +00:00
C++: support variadic emplace
Suggested by Askar Safin. http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00006.html * data/variant.hh: Implement. * tests/types.at: Check. * doc/bison.texi: Document.
This commit is contained in:
@@ -288,21 +288,22 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
AT_VAL.build (std::make_pair<std::string, std::string> ("two", "deux"));],
|
||||
[10:11, two:deux])
|
||||
|
||||
# Move-only types.
|
||||
# Move-only types, and variadic emplace.
|
||||
AT_TEST([%skeleton "]b4_skel["
|
||||
%code requires { #include <memory> }
|
||||
%define api.value.type variant],
|
||||
[[%token <std::unique_ptr<int>> '1';
|
||||
%token <std::unique_ptr<std::string>> '2';]],
|
||||
['1' '2' { std::cout << *$1 << ", " << *$2 << '\n'; }],
|
||||
%token <std::pair<int, int>> '2';]],
|
||||
['1' '2' { std::cout << *$1 << ", "
|
||||
<< $2.first << ", "
|
||||
<< $2.second << '\n'; }],
|
||||
["12"],
|
||||
[[if (res == '1')
|
||||
]AT_VAL[.emplace <std::unique_ptr<int>>
|
||||
(std::make_unique <int> (10));
|
||||
else if (res == '2')
|
||||
]AT_VAL[.emplace <std::unique_ptr<std::string>>
|
||||
(std::make_unique <std::string> ("two"));]],
|
||||
[10, two],
|
||||
]AT_VAL[.emplace <std::pair<int, int>> (21, 22);]],
|
||||
[10, 21, 22],
|
||||
[AT_REQUIRE_CXX_STD(14, [echo "$at_std not supported"; continue])])])
|
||||
])
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user