Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Proxy

Proxy object provides access to a specific Primitive, Primitive data member, or nested data member within a Primitive for an element in a container.

Description

accessor [index] or a Proxy object’s Data Member Interfaces return Proxy objects. That Proxy object represents the Primitive, Primitive data member, or nested data member within a Primitive for an element in a container. The Proxy object has the following features:

  • A value_type can be exported or imported from the Proxy.

    • Conversion operator is used to export the value_type

    • Alternatively the Proxy can be passed to the function unproxy to export a value_type

    • Assignment operator = is used to import value_type into the Proxy

  • Overloads the following operators if the underlying value_type supports the operator

    • ==, !=, <, >, <=, >=, +, -, *, /, %, &&, ||, &, |, ^, ~, *, +, -, !, +=, -=, *=, /=, %=, >>=, <<=, &=, |=, ^=, ++, --

    • When an operator is called the following occurs:

      • value_type is exported

      • The operator applied to the exported value

      • If the operator was an assignment, the result is imported back into the Member and returns the proxy

      • Otherwise a result is returned.

  • Data Member Interface.

    • For each data member of value_type

      • A member access method is defined which returns a Member proxy representing just that member.

Member Type

Description

typedef implementation-defined value_type

The type of the data the Proxy is representing

Member

Description

operator value_type const () const;

Returns: exports a copy of the Proxy’s value.

NOTE: constant return value prevents rvalue assignment for structs offering some protection against code that expected a modifiable reference.

const value_type &
operator = (const value_type &a_value);

Imports a_value into container at the position the Proxy is representing.

Returns: the same constant value_type it was passed.

NOTE: This behavior is different from traditional assignment operators that return *this. Choice was to enable efficient chaining of assignment operators versus returning a Proxy which would have to export the value it had just imported.

Proxy & operator = (const Proxy &other);

Exports value from the other Proxy and imports it.

Returns: A reference to this Proxy obect.

auto name_of_values_data_member_1()const;

Returns: Proxy instance representing the 1st data member of the value_type

NOTE: actual method name is the name of the value_type’s 1st data member

auto name_of_values_data_member_2()const;

Returns: Proxy instance representing the 2nd data member of the value_type.

NOTE: actual method name is the name of the value_type’s 2nd data member.

auto name_of_values_data_member_...()const;

Returns: Proxy instance representing the ...th data member of the value_type.

NOTE: actual method name is the name of the value_type’s …th data member.

auto name_of_values_data_member_N()const;

Returns: Proxy instance representing the Nth data member of the value_type.

NOTE: actual method name is the name of the value_type’s Nth data member