Skip to content

It would be nice to have an identity function object #17

Open
@mclow

Description

@mclow

From the -users ML:

I use the following function on a regular basis:

template < class P_T > P_T const &same (P_T const &p) { return p; }

I use it for two purposes:

  1. to pass an identity function to an API that expects a unary function,
  2. to help the compiler identify the right chain of type conversions.

The standard uses static_cast for (2), which could be used but it disables
some compile-time verification so I would rather not use static_cast when
not absolutely necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions