Compare commits

...

3 commits

Author SHA1 Message Date
Rasmus Karlsson 89a7052a94 Update the changelog entry phrasing 2024-01-26 22:50:51 +01:00
Rasmus Karlsson c98a0cf460 Merge remote-tracking branch 'origin/master' into feature/allow_input.text_from_hotkeys 2024-01-26 22:43:23 +01:00
nerix 5cd4c51f07
chore: specialize Atomic<std::shared_ptr<T>> (#5133) 2024-01-26 21:55:30 +01:00
2 changed files with 69 additions and 2 deletions

View file

@ -26,7 +26,7 @@
- Minor: Normalized the input padding between light & dark themes. (#5095)
- Minor: Add `--activate <channel>` (or `-a`) command line option to activate or add a Twitch channel. (#5111)
- Minor: Chatters from recent-messages are now added to autocompletion. (#5116)
- Minor: Add support for input.text in commands run with hotkeys. (#5130)
- Minor: Added support for the `{input.text}` placeholder in the **Split** -> **Run a command** hotkey. (#5130)
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)
@ -134,6 +134,7 @@
- Dev: Added benchmark for parsing and building recent messages. (#5071)
- Dev: Boost is depended on as a header-only library when using conan. (#5107)
- Dev: Added signal to invalidate paint buffers of channel views without forcing a relayout. (#5123)
- Dev: Specialize `Atomic<std::shared_ptr<T>>` if underlying standard library supports it. (#5133)
## 2.4.6

View file

@ -1,5 +1,7 @@
#pragma once
#include <atomic>
#include <memory>
#include <mutex>
namespace chatterino {
@ -9,9 +11,10 @@ class Atomic
{
public:
Atomic() = default;
~Atomic() = default;
Atomic(T &&val)
: value_(val)
: value_(std::move(val))
{
}
@ -47,4 +50,67 @@ private:
T value_;
};
#if defined(__cpp_lib_atomic_shared_ptr) && defined(__cpp_concepts)
template <typename T>
class Atomic<std::shared_ptr<T>>
{
// Atomic<std::shared_ptr<T>> must be instantated with a const T
};
template <typename T>
requires std::is_const_v<T>
class Atomic<std::shared_ptr<T>>
{
public:
Atomic() = default;
~Atomic() = default;
Atomic(T &&val)
: value_(std::make_shared<T>(std::move(val)))
{
}
Atomic(std::shared_ptr<T> &&val)
: value_(std::move(val))
{
}
Atomic(const Atomic &) = delete;
Atomic &operator=(const Atomic &) = delete;
Atomic(Atomic &&) = delete;
Atomic &operator=(Atomic &&) = delete;
std::shared_ptr<T> get() const
{
return this->value_.load();
}
void set(const T &val)
{
this->value_.store(std::make_shared<T>(val));
}
void set(T &&val)
{
this->value_.store(std::make_shared<T>(std::move(val)));
}
void set(const std::shared_ptr<T> &val)
{
this->value_.store(val);
}
void set(std::shared_ptr<T> &&val)
{
this->value_.store(std::move(val));
}
private:
std::atomic<std::shared_ptr<T>> value_;
};
#endif
} // namespace chatterino