Modern C++ Features#

Important to know the following modern C++ features when working with gunrock/gunrock. Please familiarize yourself with these before looking at the Programming API.

Lambda Expressions (since C++11)#

Constructs a closure: an unnamed function object capable of capturing variables in scope.

A simple example.

auto sample_lambda = [=] __host__ __device__(int blah) -> bool {
    return true;
};

Variadic Arguments (since C++11)#

Allows a function to accept any number of extra arguments. Indicated by a trailing ... (other than one introducing a pack expansion) (since C++11) following the parameter-list of a function declaration.

  • Extensively used within the implementation of graph_t class.

template <memory_space_t space,
          typename vertex_t,
          typename edge_t,
          typename weight_t,
          class... graph_view_t>
class graph_t : public graph_view_t... { 
    // ... implementation.
}

Constexpr (since C++11)#

constexpr - specifies that the value of a variable or function can appear in constant expressions