mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-20 10:17:05 +00:00
Apply std::invocable.
This commit is contained in:
@@ -51,14 +51,16 @@ inline void test_gl_error() {}
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
template <typename Func>
|
||||
inline void test_gl(const Func &&perform) {
|
||||
template <typename FuncT>
|
||||
requires std::invocable<FuncT>
|
||||
inline void test_gl(const FuncT &&perform) {
|
||||
perform();
|
||||
test_gl_error();
|
||||
}
|
||||
#else
|
||||
template <typename Func>
|
||||
inline void test_gl(const Func &&perform) {
|
||||
template <typename FuncT>
|
||||
requires std::invocable<FuncT>
|
||||
inline void test_gl(const FuncT &&perform) {
|
||||
perform();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Shader.hpp"
|
||||
|
||||
#include "Outputs/Log.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace Outputs::Display::OpenGL;
|
||||
@@ -221,6 +222,7 @@ void Shader::enable_vertex_attribute_with_pointer(
|
||||
}
|
||||
|
||||
template <typename FuncT>
|
||||
requires std::invocable<FuncT, GLint>
|
||||
void Shader::with_location(const std::string &name, FuncT &&function) {
|
||||
const GLint location = glGetUniformLocation(shader_program_, name.c_str());
|
||||
if(location == -1) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Outputs/OpenGL/API.hpp"
|
||||
#include "Outputs/OpenGL/OpenGL.hpp"
|
||||
|
||||
#include <concepts>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -158,6 +159,7 @@ private:
|
||||
);
|
||||
|
||||
template <typename FuncT>
|
||||
requires std::invocable<FuncT, GLint>
|
||||
void with_location(const std::string &, FuncT &&);
|
||||
|
||||
GLuint compile_shader(const std::string &source, GLenum type);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <concepts>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
@@ -144,11 +145,12 @@ public:
|
||||
return coefficients_.end();
|
||||
}
|
||||
|
||||
template <typename IteratorT>
|
||||
template <typename IteratorT, typename FuncT>
|
||||
requires std::invocable<FuncT, IteratorT, CoefficientType>
|
||||
void copy_to(
|
||||
IteratorT begin,
|
||||
IteratorT end,
|
||||
const std::function<void(IteratorT, CoefficientType)> &applier
|
||||
FuncT &&applier
|
||||
) const {
|
||||
auto dest = begin;
|
||||
auto src = coefficients_.begin();
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "ClockReceiver/ClockReceiver.hpp"
|
||||
#include "ClockReceiver/ClockingHintSource.hpp"
|
||||
|
||||
#include <concepts>
|
||||
|
||||
namespace Storage::Disk {
|
||||
|
||||
/*!
|
||||
@@ -133,7 +135,9 @@ protected:
|
||||
return *drives_[index];
|
||||
}
|
||||
|
||||
void for_all_drives(const std::function<void(Drive &, size_t)> &func) {
|
||||
template <typename FuncT>
|
||||
requires std::invocable<FuncT, Drive &, size_t>
|
||||
void for_all_drives(FuncT &&func) {
|
||||
size_t index = 0;
|
||||
for(auto &drive: drives_) {
|
||||
func(*drive, index);
|
||||
|
||||
Reference in New Issue
Block a user