Skip to content

Why return a default constructed ip address on failure? #75

@mclow

Description

@mclow

[internet.address.v4.creation]/6 says (about make_address_v4):

Returns: If successful, an address_v4 value corresponding to the string str. Otherwise address_v4().

What is the benefit for returning all zeros?
Why not just say something like "Otherwise, the return value is unspecified".

When I'm parsing these bits, if I get a failure, I have to either (1) zero the internal array, or (2) return a different value, which defeats some cases of RVO.
(Obviously, this is not specific to address_v4]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions