matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
Utils.hpp File Reference

Defines utility functions, macros, algorithms, and data structures. More...

#include <format>
#include <source_location>
#include <vector>
#include <mutex>
#include <filesystem>
#include <functional>
#include <unordered_set>
#include <type_traits>
Include dependency graph for Utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  engine
 
namespace  engine::util
 
namespace  engine::util::alg
 Contains algorithm.
 
namespace  engine::util::ds
 

Macros

#define defer   auto CONCAT(defer_stmt_, __LINE__) = MakeDeferImpl() << [&]
 Creates a defer statement.
 
#define range(container)   std::begin(container), std::end(container)
 Shorthand for std::begin(container), std::end(container).
 
#define crange(container)   std::cbegin(container), std::cend(container)
 Shorthand for std::cbegin(container), std::cend(container).
 

Functions

void engine::util::tracing_on ()
 Turns on tracing.
 
void engine::util::tracing_off ()
 Turns off tracing.
 
void engine::util::trace (std::source_location location=std::source_location::current())
 Traces a function call.
 
std::string engine::util::read_text_file (const std::filesystem::path &path)
 Reads a text file.
 
template<typename Action >
void engine::util::once (Action action)
 Calls an action once.
 
template<typename Container , typename T >
bool engine::util::alg::contains (const Container &container, const T &value)
 Checks if a container contains a value. Shorthand for std::find.
 
template<typename It , typename Adjacent >
void engine::util::alg::topological_sort (It first, It last, Adjacent adjacent)
 Topologically sorts a directed acyclic graph represented by a range and an adjacent function. Make sure that the graph is acyclic before calling this function. Use has_cycle to check for cycles.
 
template<typename It , typename Adjacent , typename OutputIt = std::nullptr_t>
bool engine::util::alg::has_cycle (It first, It last, Adjacent adjacent, OutputIt cycle_output=nullptr)
 Checks if a graph represented by a range and an adjacent function has a cycle.
 

Detailed Description

Defines utility functions, macros, algorithms, and data structures.

Macro Definition Documentation

◆ defer

#define defer   auto CONCAT(defer_stmt_, __LINE__) = MakeDeferImpl() << [&]

Creates a defer statement.

Parameters
fThe function to defer.
{
unsigned char * image = stbi_load("image.png", &width, &height, &channels, 0);
defer { stbi_image_free(image); };
// use image
} <-- defer statement is executed here
#define defer
Creates a defer statement.
Definition Utils.hpp:63

◆ range

#define range (   container)    std::begin(container), std::end(container)

Shorthand for std::begin(container), std::end(container).

◆ crange

#define crange (   container)    std::cbegin(container), std::cend(container)

Shorthand for std::cbegin(container), std::cend(container).