Code Monkey home page Code Monkey logo

clangformatstyle's Introduction

Clang Format Style

My .clang-format file.

// Max line width set artificially low to illustrate wrapping. Real max 
// line width is 120 characters.
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <iterator>

#define BIT_MASK 0xDEADBEAF

#define MULTILINE_DEF(a, b)         \
    if((a) > 2) {                   \
        auto temp = (b) / 2;        \
        (b) += 10;                  \
        someFunctionCall((a), (b)); \
    }

namespace LevelOneNamespace {
namespace LevelTwoNamespace {

class Foo: Bar {
public:
    Foo(int bar, int baz): bar_(bar), baz_(baz) {
        // Pass
    }

    Foo(int bar, int baz, int fizz, int buzz, int woz, int puz):
        bar_(bar),
        baz_(baz),
        fizz_(fizz),
        buzz_(buzz),
        woz_(woz),
        puz_(puz) {
        // Pass
    }

private:
    int bar_;
    int baz_;
    int fizz_;
    int buzz_;
    int woz_;
    int puz_;
}

template<typename T, int size>
bool is_sorted(T (&array)[size]) {
    return std::adjacent_find(array, array + size, std::greater<T>())
           == array + size;
}

std::vector<uint32_t> returnVector(
    uint32_t *                            LongNameForParameter1,
    double *                              LongNameForParameter2,
    const float &                         LongNameForParameter3,
    const std::map<std::string, int32_t> &LongNameForParameter4) {
    // TODO: This is a long comment that allows you to understand how
    // long comments will be trimmed. Here should be deep thought but
    // it's just not right time for this

    for(auto &i: LongNameForParameter4) {
        auto b = someFunctionCall(
            static_cast<int16_t>(*LongNameForParameter2),
            reinterpret_cast<float *>(LongNameForParameter2));
        i.second++;
    }

    do {
        if(a)
            a--;
        else
            a++;
    } while(false);

    return {};
}

}  // namespace LevelTwoNamespace
}  // namespace LevelOneNamespace

int main() {
    std::srand(std::time(0));

    int list[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};

    do {
        std::random_shuffle(list, list + 9);
    } while(is_sorted(list));

    int score = 0;

    do {
        std::cout << "Current list: ";
        std::copy(list,
                  list + 9,
                  std::ostream_iterator<int>(std::cout, " "));

        int rev;
        while(true) {
            std::cout << "\nDigits to reverse? ";
            std::cin >> rev;
            if(rev > 1 && rev < 10)
                break;
            std::cout << "Please enter a value "
                         "between 2 and 9.";
        }

        ++score;
        std::reverse(list, list + rev);
    } while(!is_sorted(list));

    std::cout << "Congratulations, you sorted the list.\n"
              << "You needed " << score << " reversals." << std::endl;
    return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.