Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static_assert using Excalibur::HashTable<string, unique_ptr<...>> and Emplace #15

Open
naricc opened this issue Nov 6, 2024 · 0 comments

Comments

@naricc
Copy link

naricc commented Nov 6, 2024

I am seeing this error:

am seeing this static_assert error when trying to use build a program using ExcaliburHash<string, unique_ptr<...>> and Emplace for at least some kinds of unique_ptr:

In file included from hash_test.cpp:3:
../ExcaliburHash/ExcaliburHash/ExcaliburHash.h: In instantiation of 'std::pair<Excalibur::HashTable<TKey, TValue, kNumInlineItems, TKeyInfo>::TIteratorKV<TValue>, bool> Excalibur::HashTable<TKey, TValue, kNumInlineItems, TKeyInfo>::emplace(TK&&, Args&& ...) [with TK = const char (&)[1]; Args = {std::unique_ptr<StringInternStringData, std::default_delete<StringInternStringData> >}; TKey = std::__cxx11::basic_string<char>; TValue = std::unique_ptr<StringInternStringData>; unsigned int kNumInlineItems = 1; TKeyInfo = Excalibur::KeyInfo<std::__cxx11::basic_string<char> >]':
hash_test.cpp:27:34:   required from here
  27 |     auto inserted = exMap.emplace("", make_unique<StringInternStringData>(""));
     |                     ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../ExcaliburHash/ExcaliburHash/ExcaliburHash.h:741:119: error: static assertion failed: Expected unversal reference of TKey type. Wrong key type?
 741 |         static_assert(std::is_same<TKey, typename std::remove_const<typename std::remove_reference<TK>::type>::type>::value,
     |                                                                                                                       ^~~~~
../ExcaliburHash/ExcaliburHash/ExcaliburHash.h:741:119: note: 'std::integral_constant<bool, false>::value' evaluates to false

contests of hash_test3.cpp

#include <memory>
#include "ExcaliburHash.h"

using namespace std;

class StringInternStringData
{
public:
	inline StringInternStringData()
		: refCount(0), string()
	{	}

	inline StringInternStringData(const std::string &string)
		: refCount(1), string(string)
	{	}

    int64_t refCount;
	std::string string;
};


int main(void) 
{
    Excalibur::HashTable<string, unique_ptr<StringInternStringData>>  exMap;

    auto inserted = exMap.emplace("", make_unique<StringInternStringData>(""));

    // auto res = inserted.first->second.get();
    return 0;
}

If I replace Excalibur::HashTable with a std::map, it works fine (or at least builds). So I am confused if I am doing something wrong, or the interface of ExcaliburHash is different some how, or what the problem is.

Building was attempted with g++-14

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

No branches or pull requests

1 participant