Skip to content

Instantly share code, notes, and snippets.

@tetsuok
Last active January 25, 2016 09:32
Show Gist options
  • Select an option

  • Save tetsuok/7ef5123628dbc9b6e056 to your computer and use it in GitHub Desktop.

Select an option

Save tetsuok/7ef5123628dbc9b6e056 to your computer and use it in GitHub Desktop.

Revisions

  1. tetsuok revised this gist Jan 25, 2016. 1 changed file with 12 additions and 8 deletions.
    20 changes: 12 additions & 8 deletions auto.cc
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,17 @@
    // g++ -std=c++14 auto.cc
    #include <stdio.h>
    // g++ -std=c++11 auto.cc
    #include <vector>
    #include <string>
    #include <iostream>

    class Node {
    public:
    Node(int a, int b) { printf("ctor\n"); }
    static auto create(int a, int b) { return Node(a, b); }
    };
    static std::vector<std::string> Foo() {
    decltype(Foo()) v;
    v.push_back("aii");
    return v;
    }

    int main() {
    auto n = Node::create(1, 2);
    auto v = Foo();
    std::cout << v.back() << std::endl;

    return 0;
    }
  2. tetsuok revised this gist Jan 25, 2016. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions auto.cc
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,6 @@
    // g++ -std=c++14 auto.cc
    #include <stdio.h>

    using namespace std;

    class Node {
    public:
    Node(int a, int b) { printf("ctor\n"); }
  3. tetsuok revised this gist Jan 25, 2016. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions auto.cc
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,6 @@ using namespace std;
    class Node {
    public:
    Node(int a, int b) { printf("ctor\n"); }
    Node(const Node&) { printf("copy ctor\n"); }

    static auto create(int a, int b) { return Node(a, b); }
    };

  4. tetsuok created this gist Jan 25, 2016.
    17 changes: 17 additions & 0 deletions auto.cc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // g++ -std=c++14 auto.cc
    #include <stdio.h>

    using namespace std;

    class Node {
    public:
    Node(int a, int b) { printf("ctor\n"); }
    Node(const Node&) { printf("copy ctor\n"); }

    static auto create(int a, int b) { return Node(a, b); }
    };

    int main() {
    auto n = Node::create(1, 2);
    return 0;
    }