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
{{ message }}
Repository navigation
Commit 5865db2
Browse filesBrowse the repository at this point in the historyBrowse files
Drop Init marker for rules that forward arguments (#571)
The manual Init marker on rules such as vector::emplace_back was used to
encode semantic information about the rule: the forward pack is used to
construct an element type.
For automatically generated rules this is not a good approach. The
signature does not tell how forwarded arguments are used, this
information exists as text in the description of the standard, for
example:
```cpp
std::map<Key,T,Compare,Allocator>::emplace
template< class... Args > std::pair<iterator, bool> emplace( Args&&... args )
```
_Inserts a new element into the container constructed in-place with the
given args, if there is no element with the key in the container. **The
constructor of the new element (i.e. std::pair<const Key, T>) is called
with exactly the same arguments as supplied to emplace, forwarded via
std::forward<Args>(args)....**_
---
This PR moves the Init marker in the Rust translation:
```cpp
fn f67<T1: CppLess + Clone + ByteRepr + 'static, T2: Default + Clone + ByteRepr + 'static>(
a0: Ptr<Map<T1, (Value<T1>, Value<T2>)>>,
// init is the pack argument which builds typename std::map<T1, T2, T3, T4>::value_type
// as the text of the standard says
init: cpp_type!("typename std::map<T1, T2, T3, T4>::value_type", (Value<T1>, Value<T2>)),
) -> (Value<BidirectionalIterator<(Value<T1>, Value<T2>)>>, Value<bool>)
```
cpp_type has no semantic meaning for the rule, it expands to the second
argument, i.e. `(Value<T1>, Value<T2>)`.
---
I also added rules for std::any which builds a `decay_t<T>` using the
forwarded arguments. I wanted to make sure that this also works.
0 commit comments