All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ADL module

Provides an interface for common ADL (Argument Dependent Lookup) functions. More...

Functions

template<size_t N, typename T >
constexpr auto gears::adl::get (T &&t) -> decltype(detail::adl_get< N >(std::declval< T >()))
 ADL enabled get function for tuple-like classes. More...
 
template<typename T >
constexpr auto gears::adl::begin (T &&t) -> decltype(detail::adl_begin(std::declval< T >()))
 ADL-enabled begin. More...
 
template<typename T >
constexpr auto gears::adl::end (T &&t) -> decltype(detail::adl_end(std::declval< T >()))
 ADL-enabled end. More...
 
template<typename T , typename U , typename R = decltype(detail::adl_swap(std::declval<T>(), std::declval<U>()))>
constexpr R gears::adl::swap (T &&t, U &&u) noexcept(detail::adl_swap(std::declval< T >(), std::declval< U >()))
 ADL-enabled swap. More...
 

Detailed Description

This module is very simple, allowing for an ADL-enabled function calls. This is useful because it allows you to write generic code that relies on certain functions without actually having to specify the using statement for every function in every line.

Example usage:

#include <gears/adl/get.hpp>
#include <tuple>
#include <iostream>
namespace adl = gears::adl;
namespace my {
struct get_example {
int x;
int y;
};
template<size_t N>
constexpr int get(const get_example& g) {
return N == 0 ? g.x : g.y;
}
} // my
int main() {
auto tup = std::make_tuple("hello", 3.14);
my::get_example f = {10, 11};
std::cout << adl::get<0>(tup) << ' ' << adl::get<0>(f);
}

Output:

hello 10

Function Documentation

template<typename T >
constexpr auto gears::adl::begin ( T &&  t) -> decltype(detail::adl_begin(std::declval<T>()))

Allows for retrieval of std::begin and specialisations of begin through argument dependent lookup. Equivalent to doing the following:

using std::begin;
begin(t);
Parameters
tObject with begin interface
Returns
automatically deduced return value of begin(t)

Definition at line 61 of file adl/iterator.hpp.

template<typename T >
constexpr auto gears::adl::end ( T &&  t) -> decltype(detail::adl_end(std::declval<T>()))

Allows for retrieval of std::end and specialisations of end through argument dependent lookup. Equivalent to doing the following:

using std::end;
end(t);
Parameters
tObject with end interface
Returns
automatically deduced return value of end(t)

Definition at line 81 of file adl/iterator.hpp.

template<size_t N, typename T >
constexpr auto gears::adl::get ( T &&  t) -> decltype(detail::adl_get<N>(std::declval<T>()))

Allows for argument dependent lookup of std::get and overloaded specialisations of get.

using std::get;
get<N>(t);
Template Parameters
NIndex to retrieve
Parameters
tTuple-like class to retrieve index from
Returns
automatically deduced return value of get<N>(t)

Definition at line 56 of file get.hpp.

template<typename T , typename U , typename R = decltype(detail::adl_swap(std::declval<T>(), std::declval<U>()))>
constexpr R gears::adl::swap ( T &&  t,
U &&  u 
)
noexcept

Allows for ADL of std::swap. Equivalent to the following:

using std::swap;
swap(t, u);
Parameters
tFirst element to swap
uSecond element to swap
Returns
automatically deduced return value of swap(t, u)

Definition at line 51 of file swap.hpp.