| Home | Libraries | People | FAQ | More

## 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.

      // public member functions
      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 member functions

1.     field(const std::string & field);

   Creates a new field functor with `field`.