|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
DRY (Don't Repeat Yourself) utilities and macros. More...
#include <cstddef>#include <tuple>#include <functional>#include <sstream>#include <initializer_list>#include <ahFunctional.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| struct | Aleph::Dft_Pair_Cmp< Key, Data, Cmp > |
| Default comparator for pair types in hash maps. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Macros | |
| #define | Special_Ctors(Set_Type, Type) |
| Generates special constructors for containers. | |
| #define | Generic_Items(Type) |
| Generates an items() method returning all container elements. | |
| #define | Generate_Proxy_Operator(Class_Name) |
| Generates operator[] for map-like containers. | |
Functions | |
| template<typename Type > | |
| std::string | Aleph::to_str (const Type &d) |
| Converts any streamable value to string. | |
| template<typename Key , typename Data > | |
| std::pair< Key, Data > * | Aleph::key_to_pair (Key *ptr) |
| Converts a pointer to Key to a pointer to the containing pair. | |
| template<typename Key , typename Data > | |
| const std::pair< Key, Data > * | Aleph::key_to_pair (const Key *ptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename Key , typename Data > | |
| std::pair< Key, Data > * | Aleph::data_to_pair (Data *ptr) |
| Converts a pointer to Data to a pointer to the containing pair. | |
| template<typename Key , typename Data > | |
| const std::pair< Key, Data > * | Aleph::data_to_pair (const Data *ptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
DRY (Don't Repeat Yourself) utilities and macros.
This file provides utility macros that implement common patterns to avoid code repetition.
Special_Ctors(Set_Type, Type): Generates constructors from lists, iterators, and initializer_list. Cannot be replaced by CRTP because constructors don't inherit in C++.Generic_Items(Type): Generates an items() method that returns all elements in a container.Generate_Proxy_Operator(Class_Name): Generates operator[] for map-like containers.The following macros have been migrated to CRTP classes in ah-dry.H and ah-dry-mixin.H:
Generic_Traverse → GenericTraverse class in ah-dry.HLocate_Functions → LocateFunctions class in ah-dry.HFunctional_Methods → FunctionalMethods class in ah-dry.HGeneric_Keys → GenericItems class in ah-dry.HEqual_To_Method → EqualToMethod class in ah-dry.HMap_Sequences_Methods → MapSequencesMethods class in ah-dry.HFor new code, prefer using the CRTP classes from ah-dry.H or the documented mixins from ah-dry-mixin.H.
Definition in file ahDry.H.
| #define Generate_Proxy_Operator | ( | Class_Name | ) |
Generates operator[] for map-like containers.
| Class_Name | The container class name (unused, kept for compatibility) |
| #define Generic_Items | ( | Type | ) |
Generates an items() method returning all container elements.
| Type | The element type |
| #define Special_Ctors | ( | Set_Type, | |
| Type | |||
| ) |
Generates special constructors for containers.
This macro generates three constructors:
| Set_Type | The container class name |
| Type | The element type |
Example: