跳到正文

个人记录

Sublime 配置

_auto_约 7 分钟
原文

这是 2026年10月17日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年10月17日
收录
2026年10月17日
更新
2026年11月12日
篇幅
约 7 分钟
获赞
1

版本

  1. v2当前
  2. v1

编译命令

JSON
{
    "shell_cmd": "g++ -std=c++17 -m64 -Wall -Wextra -static -D__LOCAL__ -Wl,--stack,1073741824 -finput-charset=UTF-8 -fexec-charset=UTF-8 -I\"D:/My Project/bin/Debug\" -I\"D:/My Project/bin\" -o _run_.exe \"$file\" && start \"$file_base_name\" cmd /c \"D:\\My Project\\bin\\run.bat\"",
    "working_dir": "$file_path",
    "file_regex": "^(.*):([0-9]+):([0-9]+): (?:fatal )?error: (.*)$",
    "selector": "source.c++",
    "encoding": "utf-8"
}

D:\My Project\bin\timer.ps1

ps1
param([string]$Exe)
$sw = [Diagnostics.Stopwatch]::StartNew()
& $Exe
$sw.Stop()
Write-Host ''
Write-Host ('({0} ms)' -f $sw.ElapsedMilliseconds)

D:\My Project\bin\run.bat

bat
@echo off
chcp 65001 >nul
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0timer.ps1" ".\_run_.exe"
pause

D:\My Project\bin\Debug.h

h
namespace _Debug {
    template<typename T>
    struct isContainer {
    private:
        template<typename U>
        static auto test(int) -> decltype(
            std::declval<U>().begin(),
            std::declval<U>().end(),
            std::true_type{}
        );
        template<typename>
        static auto test(...) -> std::false_type;
    public:
        static const bool value = decltype(test<T>(0))::value;
    };

    template<typename T1, typename T2>
    std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
        os << "(" << p.first << ", " << p.second << ")";
        return os;
    }

    template<typename T, size_t N>
    void PrintArray(const T (&arr)[N], std::ostream& os) {
        os << "[";
        for (size_t i = 0; i < N; ++i) {
            if (i) os << ", ";
            os << arr[i];
        }
        os << "]";
    }

    template<typename T>
    void PrintContainer(const T& v, std::ostream& os) {
        os << "[";
        bool first = true;
        for (const auto& elem : v) {
            if (!first) os << ", ";
            first = false;
            os << elem;
        }
        os << "]";
    }

    struct DebugStream {
        template<typename T>
        auto operator<<(const T& val) ->
            typename std::enable_if<!isContainer<T>::value, DebugStream&>::type {
            std::cerr << val;
            return *this;
        }

        template<typename T>
        auto operator<<(const T& container) ->
            decltype(container.begin(), container.end(), *this) {
            PrintContainer(container, std::cerr);
            return *this;
        }

        template<typename T, size_t N>
        DebugStream& operator<<(const T (&arr)[N]) {
            PrintArray(arr, std::cerr);
            return *this;
        }

        DebugStream& operator<<(const char* s) {
            std::cerr << s;
            return *this;
        }

        DebugStream& operator<<(std::ostream& (*manip)(std::ostream&)) {
            std::cerr << manip;
            return *this;
        }
    };

    namespace debug {
        DebugStream dout;
        #define debug(x) { dout << "["; dout << __LINE__; dout << "] "; dout << #x; dout << " = "; dout << x; dout << "\n"; }
    }
}
using namespace _Debug::debug;

缺省源

C++
// Written by hwz007

#include <bits/stdc++.h>
#ifdef __LOCAL__
#include <Debug.h>
#else
#define debug(x)
#endif

namespace _Typedef {
    using uint = unsigned int;
    using ll = long long;
    using ull = unsigned long long;
    using bint = __int128;
    using lld = long double;
    using pii = std::pair<int, int>;
    using pll = std::pair<long long, long long>; }
using namespace _Typedef;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    return 0;
}