Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template field

boost::compute::field

Synopsis

// In header: <boost/compute/functional/field.hpp>

template<typename T> 
class field {
public:
  // types
  typedef T result_type;  // Result type. 

  // construct/copy/destruct
  field(const std::string &);
};

Description

Returns the named field from a value.

The template-type T specifies the field's value type. Note that the value type must match the actual type of the field otherwise runtime compilation or logic errors may occur.

For example, to access the second field in a std::pair<int, float> object:

field<float>("second");

This can also be used with vector types to access individual components as well as perform swizzle operations.

For example, to access the first and third components of an int vector type (e.g. int4):

field<int2_>("xz");

See Also:

get<N>

field public construct/copy/destruct

  1. field(const std::string & field);
    Creates a new field functor with field.

PrevUpHomeNext