Skip to content

Instantly share code, notes, and snippets.

@wancw
Created January 12, 2015 12:50
Show Gist options
  • Select an option

  • Save wancw/771bcb03826af0bd8ca6 to your computer and use it in GitHub Desktop.

Select an option

Save wancw/771bcb03826af0bd8ca6 to your computer and use it in GitHub Desktop.

Revisions

  1. wancw created this gist Jan 12, 2015.
    22 changes: 22 additions & 0 deletions conversion.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    class To{};

    #include <utility>

    class From{
    public:
    /* This will cause compilation error under Clang (3.5) with c++11 standard */

    operator const To() { return To(); }

    /* Any one of below works fine */

    //explicit operator const To() { return To(); }
    //operator To() { return To(); }
    //operator To &&() { return std::move(To()); }
    };

    int main() {
    From f;
    To t (f);
    return 0;
    }