# string object (STL)

Path: /sdk/add_on/scriptstdstring/

This add-on registers the `std::string` type as-is with AngelScript. This gives perfect compatibility with C++ functions that use `std::string` in parameters or as return type.

A potential drawback is that the `std::string` type is a value type, thus may increase the number of copies taken when string values are being passed around in the script code. However, this is most likely only a problem for scripts that perform a lot of string operations.

Register the type with `RegisterStdString(asIScriptEngine*)`.

See also:
  string object (reference counted)

## Public C++ interface

Refer to the `std::string` implementation for your compiler.

## Public script interface

      class string
      {
        // Constructors
        string();

        // Returns the length of the string
        uint length() const;

        // Assignment and concatenation
        string &opAssign(const string &in other);
        string &opAddAssign(const string &in other);
        string  opAdd(const string &in right) const;

        // Access individual characters
        uint8       &opIndex(uint);
        const uint8 &opIndex(uint) const;

        // Comparison operators
        bool opEquals(const string &in right) const;
        int  opCmp(const string &in right) const;

        // Automatic conversion from number types to string type
        string &opAssign(double val);
        string &opAddAssign(double val);
        string  opAdd(double val) const;
        string  opAdd_r(double val) const;

        string &opAssign(int val);
        string &opAddAssign(int val);
        string  opAdd(int val) const;
        string  opAdd_r(int val) const;

        string &opAssign(uint val);
        string &opAddAssign(uint val);
        string  opAdd(uint val) const;
        string  opAdd_r(uint val) const;

        string &opAssign(bool val);
        string &opAddAssign(bool val);
        string  opAdd(bool val) const;
        string  opAdd_r(bool val) const;
      }