C++ code style written in markdown.
Astyle code automatic formatting settings
You can use clang-format too.
Use tools like vera++
| #!/usr/bin/env bash | |
| # --slave /usr/bin/$1 $1 /usr/bin/$1-\${version} \\ | |
| function register_clang_version { | |
| local version=$1 | |
| local priority=$2 | |
| update-alternatives \ | |
| --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${version} ${priority} \ |
| #!/usr/bin/env python3 | |
| """ | |
| C++ template error message decoder and colorizer. | |
| Copyright (C) 2017 Jonas Jelten <[email protected]> | |
| Licensed under GNU GPLv3 or later. | |
| """ |
| // A compile-time method for checking the existence of a class member | |
| // @see https://general-purpose.io/2017/03/10/checking-the-existence-of-a-cpp-class-member-at-compile-time/ | |
| // This code uses "decltype" which, according to http://en.cppreference.com/w/cpp/compiler_support | |
| // should be supported by Clang 2.9+, GCC 4.3+ and MSVC 2010+ (if you have an older compiler, please upgrade :) | |
| // As of "constexpr", if not supported by your compiler, you could try "const" | |
| // or use the value as an inner enum value e.g. enum { value = ... } | |
| // check "test_has_member.cpp" for a usage example |
| struct Connection { | |
| void disconnected() | |
| { | |
| m_connection = Disconnected(); | |
| } | |
| void interrupted() | |
| { | |
| m_connection = std::visit(InterruptedEvent(*this), m_connection); | |
| } |
| main() { | |
| # Use colors, but only if connected to a terminal, and that terminal | |
| # supports them. | |
| if which tput >/dev/null 2>&1; then | |
| ncolors=$(tput colors) | |
| fi | |
| if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then | |
| RED="$(tput setaf 1)" | |
| GREEN="$(tput setaf 2)" | |
| YELLOW="$(tput setaf 3)" |
C++ code style written in markdown.
Astyle code automatic formatting settings
You can use clang-format too.
Use tools like vera++
| // Source: http://codereview.stackexchange.com/questions/95464/is-the-copy-swap-idiom-implemented-here-correctly | |
| class Array | |
| { | |
| int size; | |
| int* data; | |
| public: | |
| Array(Array const& copy) | |
| : size(copy.size) | |
| , data(new int[size]) |
| #ifndef __CONSUMERPRODUCERQUEUE_H__ | |
| #define __CONSUMERPRODUCERQUEUE_H__ | |
| #include <queue> | |
| #include <mutex> | |
| #include <condition_variable> | |
| /* | |
| * Some references in order | |
| * |
| // Sean Parent. Inheritance Is The Base Class of Evil. Going Native 2013 | |
| // Video: https://www.youtube.com/watch?v=bIhUE5uUFOA | |
| // Code : https://github.com/sean-parent/sean-parent.github.io/wiki/Papers-and-Presentations | |
| /* | |
| Copyright 2013 Adobe Systems Incorporated | |
| Distributed under the MIT License (see license at | |
| http://stlab.adobe.com/licenses.html) | |
| This file is intended as example code and is not production quality. |