Fixed: build with gcc < 5.5 - std::hash<FKey>

This commit is contained in:
Markus Gans 2021-01-01 03:46:43 +01:00
parent eb61e6fec0
commit 5b789e4110
10 changed files with 41 additions and 25 deletions

View File

@ -813,7 +813,7 @@ void MyDialog::cb_about()
finalcut::FMessageBox info ( "About" finalcut::FMessageBox info ( "About"
, line + L" FINAL CUT " + line + L"\n\n" , line + L" FINAL CUT " + line + L"\n\n"
L"Version " + libver + L"\n\n" L"Version " + libver + L"\n\n"
L"(c) 2020 by Markus Gans" L"(c) 2021 by Markus Gans"
, finalcut::FMessageBox::ButtonType::Ok , finalcut::FMessageBox::ButtonType::Ok
, finalcut::FMessageBox::ButtonType::Reject , finalcut::FMessageBox::ButtonType::Reject
, finalcut::FMessageBox::ButtonType::Reject , finalcut::FMessageBox::ButtonType::Reject
@ -1046,7 +1046,7 @@ int main (int argc, char* argv[])
{ {
const finalcut::FString ver{F_VERSION}; // Library version const finalcut::FString ver{F_VERSION}; // Library version
const finalcut::FString title { "FINAL CUT " + ver const finalcut::FString title { "FINAL CUT " + ver
+ " (C) 2020 by Markus Gans" }; + " (C) 2021 by Markus Gans" };
// Create the application object app // Create the application object app
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};

View File

@ -1,7 +1,7 @@
# #
# spec file for package finalcut # spec file for package finalcut
# #
# Copyright (c) 2020 by Markus Gans # Copyright (c) 2021 by Markus Gans
# #
%define sover 0 %define sover 0

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -799,6 +799,14 @@ enum class FKey : uInt32
Incomplete = UINT32_MAX Incomplete = UINT32_MAX
}; };
struct FKeyHash
{
std::size_t operator () (const FKey& p) const
{
return std::hash<uInt32>()(uInt32(p));
}
};
constexpr FKey operator >> (const FKey& k, const uInt32 n) noexcept constexpr FKey operator >> (const FKey& k, const uInt32 n) noexcept
{ {
return FKey(uInt32(k) >> n); return FKey(uInt32(k) >> n);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -167,7 +167,7 @@ class FDialog : public FWindow
}; };
// Using-declaration // Using-declaration
using KeyMap = std::unordered_map<FKey, std::function<void()>>; using KeyMap = std::unordered_map<FKey, std::function<void()>, FKeyHash>;
// Constant // Constant
static constexpr std::size_t MENU_BTN = 3; static constexpr std::size_t MENU_BTN = 3;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -166,7 +166,7 @@ class FLineEdit : public FWidget
private: private:
// Using-declaration // Using-declaration
using offsetPair = std::pair<std::size_t, std::size_t>; using offsetPair = std::pair<std::size_t, std::size_t>;
using KeyMap = std::unordered_map<FKey, std::function<void()>>; using KeyMap = std::unordered_map<FKey, std::function<void()>, FKeyHash>;
// Constants // Constants
static constexpr auto NOT_SET = static_cast<std::size_t>(-1); static constexpr auto NOT_SET = static_cast<std::size_t>(-1);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -275,8 +275,8 @@ class FListBox : public FWidget
private: private:
// Using-declaration // Using-declaration
using KeyMap = std::unordered_map<FKey, std::function<void()>>; using KeyMap = std::unordered_map<FKey, std::function<void()>, FKeyHash>;
using KeyMapResult = std::unordered_map<FKey, std::function<bool()>>; using KeyMapResult = std::unordered_map<FKey, std::function<bool()>, FKeyHash>;
using LazyInsert = std::function<void(FListBoxItem&, FDataAccess*, std::size_t)>; using LazyInsert = std::function<void(FListBoxItem&, FDataAccess*, std::size_t)>;
// Enumeration // Enumeration

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -406,8 +406,8 @@ class FListView : public FWidget
struct Header; // forward declaration struct Header; // forward declaration
// Using-declaration // Using-declaration
using KeyMap = std::unordered_map<FKey, std::function<void()>>; using KeyMap = std::unordered_map<FKey, std::function<void()>, FKeyHash>;
using KeyMapResult = std::unordered_map<FKey, std::function<bool()>>; using KeyMapResult = std::unordered_map<FKey, std::function<bool()>, FKeyHash>;
using HeaderItems = std::vector<Header>; using HeaderItems = std::vector<Header>;
using SortTypes = std::vector<SortType>; using SortTypes = std::vector<SortType>;

View File

@ -4,7 +4,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -150,7 +150,7 @@ class FScrollView : public FWidget
private: private:
// Using-declaration // Using-declaration
using KeyMap = std::unordered_map<FKey, std::function<void()>>; using KeyMap = std::unordered_map<FKey, std::function<void()>, FKeyHash>;
// Constants // Constants
static constexpr std::size_t vertical_border_spacing = 2; static constexpr std::size_t vertical_border_spacing = 2;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -130,6 +130,16 @@ class FTermLinux final
uChar : 4; // padding bits uChar : 4; // padding bits
}; };
struct ModifierKeyHash
{
std::size_t operator () (const ModifierKey& m_key) const
{
uChar m{};
std::memcpy(&m, &m_key, sizeof(uChar));
return std::hash<uChar>()(m);
}
};
struct RGB struct RGB
{ {
uChar red; uChar red;
@ -152,13 +162,11 @@ class FTermLinux final
{ {
std::size_t operator () (const Pair& pair) const std::size_t operator () (const Pair& pair) const
{ {
uChar m{};
std::memcpy(&m, &pair.modifier, sizeof(uChar));
size_t seed = 0; size_t seed = 0;
const auto h1 = std::hash<uChar>()(m); const auto hash1 = ModifierKeyHash()(pair.modifier);
const auto h2 = std::hash<FKey>()(pair.key); const auto hash2 = FKeyHash()(pair.key);
seed ^= h1 + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= h2 + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed; return seed;
} }
}; };

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -138,7 +138,7 @@ class FTextView : public FWidget
private: private:
// Using-declaration // Using-declaration
using KeyMap = std::unordered_map<FKey, std::function<void()>>; using KeyMap = std::unordered_map<FKey, std::function<void()>, FKeyHash>;
// Accessors // Accessors
std::size_t getTextHeight() const; std::size_t getTextHeight() const;