Caffe2 - C++ API
A deep learning, cross platform ML framework
Data Structures | Typedefs | Functions
c10::guts::detail Namespace Reference

Some added features not available in std::array. More...

Data Structures

struct  __array_traits
 
struct  __array_traits< _Tp, 0 >
 
class  DummyClassForToString
 
struct  extract_arg_by_filtered_index_
 
struct  extract_arg_by_filtered_index_< Condition, index, guts::enable_if_t< Condition< Head >::value &&index!=0 >, Head, Tail... >
 
struct  extract_arg_by_filtered_index_< Condition, index, guts::enable_if_t< Condition< Head >::value &&index==0 >, Head, Tail... >
 
struct  extract_arg_by_filtered_index_< Condition, index, guts::enable_if_t<!Condition< Head >::value >, Head, Tail... >
 
struct  extract_arg_by_filtered_index_< Condition, index, void >
 
struct  filter_map_
 
struct  filter_map_< ResultType, 0 >
 
struct  make_integer_sequence_
 
struct  make_integer_sequence_< T, N, N, Ints... >
 
struct  strip_class
 strip_class: helper to remove the class type from pointers to operator(). More...
 
struct  strip_class< Result(Class::*)(Args...) const >
 
struct  strip_class< Result(Class::*)(Args...)>
 
struct  to_string_
 
struct  to_string_< T, void_t< decltype(std::to_string(std::declval< T >()))>
 

Typedefs

template<typename T >
using strip_class_t = typename strip_class< T >::type
 

Functions

void __throw_out_of_range (std::string msg)
 
template<class T , size_t N>
constexpr bool array_equals_ (const array< T, N > &lhs, const array< T, N > &rhs, size_t current_index)
 
template<class T , size_t N>
constexpr bool array_less_ (const array< T, N > &lhs, const array< T, N > &rhs, size_t current_index)
 
template<class T , size_t N, size_t... I>
constexpr array< T, N-1 > tail_ (const array< T, N > &arg, guts::index_sequence< I... >)
 
template<class T , size_t N, size_t... I>
constexpr array< T, N+1 > prepend_ (T &&head, const array< T, N > &tail, guts::index_sequence< I... >)
 
template<class T , size_t N, size_t... I>
constexpr array< T, N > to_array_ (const T(&arr)[N], guts::index_sequence< I... >)
 
template<class F , class Tuple , std::size_t... I>
constexpr auto apply_impl (F &&f, Tuple &&t, guts::index_sequence< I... >) -> decltype(forward< F >(f)(std::get< I >(forward< Tuple >(t))...))
 

Detailed Description

Some added features not available in std::array.

Use filter_map to map a subset of the arguments to values.

Use extract_arg_by_filtered_index to return the i-th argument whose type fulfills a given type trait.

Convert a C array into a std::array.

Only call these at compile time, they're slow if called at runtime. Examples: tail({2, 3, 4}) == {3, 4} prepend(2, {3, 4}) == {2, 3, 4}

Example: int source[3] = {2, 3, 4}; std::array<int, 3> target = to_std_array(source);

The argument itself is perfectly forwarded.

Example: std::string arg1 = "Hello"; std::string arg2 = "World"; std::string&& result = extract_arg_by_filtered_index<is_string, 1>(0, arg1, 2.0, std::move(arg2));

Warning: Taking the result by rvalue reference can cause segfaults because ownership will not be passed on from the original reference. The original reference dies after the expression and the resulting

The subset is defined by type traits, and will be evaluated at compile time. At runtime, it will just loop over the pre-filtered arguments to create an std::array.

Example: // in C++14 std::array<double, 2> result = filter_map<double, std::is_integral>([] (auto a) {return (double)a;}, 3, "bla", 4); // result == {3.0, 4.0}

// same example in C++11 struct my_map { template<class T> constexpr double operator()(T a) { return (double)a; } }; std::array<double, 2> result = filter_map<double, std::is_integral>(my_map(), 3, "bla", 4); // result == {3.0, 4.0}