Skip to content

Conversation

@Emmankoko
Copy link
Collaborator

This PR is broken down into three simple commits on the following

  1. worked out the available and bindable functions for std::unordered_map targeting CppRuntime_Gcc
  2. Added a new stdcpp.Hashtable module for unordered_map. it is imported in stdcpp.unordered_map module for a better code organization
  3. Added tests that cover functions that have been worked on.

Emmanuel Nyarko added 2 commits March 8, 2024 03:11
This serves as the beginning module for unordered_map container. currently, this
serves only Gcc runtime with the possible bindable functions for now
@Emmankoko Emmankoko force-pushed the linux/unordered_map branch 3 times, most recently from 6f130d0 to 3cc444f Compare March 8, 2024 08:11
@Emmankoko Emmankoko force-pushed the linux/unordered_map branch from 3cc444f to aac8641 Compare March 8, 2024 08:14
@@ -0,0 +1,103 @@
/**
* D header file for interaction with C++ std::unordered_map.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See_Also:
https://en.cppreference.com/w/cpp/container/unordered_map

Comment on lines 19 to 20
alias unordered_map(Key, value) = unordered_map!(Key, value, hash!Key, equal_to!Key, allocator!(pair!(const(Key), value)));
extern(C++, class) struct unordered_map(Key, value, Hash, KeyEqual, Alloc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use default parameter for better API.

Suggested change
alias unordered_map(Key, value) = unordered_map!(Key, value, hash!Key, equal_to!Key, allocator!(pair!(const(Key), value)));
extern(C++, class) struct unordered_map(Key, value, Hash, KeyEqual, Alloc)
extern(C++, class) struct unordered_map(Key, value, Hash = hash!Key, KeyEqual = equal_to!Key, Alloc = allocator!(pair!(const(Key), value)))

Unless that does not work ?

Comment on lines 52 to 57
///
extern(D) this(const ref unordered_map __a)
{
allocator_type alloc_instance = allocator_type.init;
this(__a, alloc_instance);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it extern(D)?

Comment on lines 42 to 50
///
extern(D) this(size_type __x)
{
allocator_type alloc_instance = allocator_type.init;
Hash hash_instance = Hash.init;
key_equal equal_instance = key_equal.init;
this(__x, hash_instance, equal_instance, alloc_instance);
}
///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why extern(D) ?

@kassane kassane mentioned this pull request May 12, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants