Jikka-5.0.11.1: A transpiler from Python to C++ for competitive programming
Copyright(c) Kimiyuki Onaka 2020
LicenseApache License 2.0
Maintainerkimiyuki95@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Jikka.CPlusPlus.Convert.MoveSemantics

Description

 
Synopsis

Documentation

run :: MonadError Error m => Program -> m Program Source #

run replaces superfluous copying.

Examples

Before:

vector<int> solve(vector<int> a) {
    vector<int> b = a;
    b[0] = 1;
    return b;
}

After:

vector<int> solve(vector<int> a) {
    a[0] = 1;
    return a;
}

Before:

int solve(int a, int b, int x) {
    jikka::convex_hull_trick cht = jikka::convex_hull_trick();
    cht = jikka::convex_hull_trick::persistent_add_line(cht, a, b);
    return cht.get_min(x);
}

After:

int solve(int a, int b, int x) {
    jikka::convex_hull_trick cht;
    cht = cht.add_line(a, b);
    return cht.get_min(x);
}