Repository: microsoft/terminal
File: src/renderer/gdi/paint.cpp (C++)

Code before:
{
    LOG_IF_FAILED(_FlushBufferLines());

    // Convert the target from characters to pixels.
    const auto ptTarget = coordTarget * _GetFontSize();

    // Create a brush with the gridline color, and apply it.
    wil::unique_hbrush hbr(CreateSolidBrush(gridlineColor));
    RETURN_HR_IF_NULL(E_FAIL, hbr.get());
    const auto prevBrush = wil::SelectObject(_hdcMemoryContext, hbr.get());
    RETURN_HR_IF_NULL(E_FAIL, prevBrush.get());

    // Get the font size so we know the size of the rectangle lines we'll be inscribing.
    const auto fontWidth = _GetFontSize().width;
    const auto fontHeight = _GetFontSize().height;
    const auto widthOfAllCells = fontWidth * gsl::narrow_cast<unsigned>(cchLine);

    const auto DrawLine = [=](const auto x, const auto y, const auto w, const auto h) {
        return PatBlt(_hdcMemoryContext, x, y, w, h, PATCOPY);
    };
    const auto DrawStrokedLine = [&](const auto x, const auto y, const auto w) {
        RETURN_HR_IF(E_FAIL, !MoveToEx(_hdcMemoryContext, x, y, nullptr));
        RETURN_HR_IF(E_FAIL, !LineTo(_hdcMemoryContext, x + w, y));
        return S_OK;
    };
    const auto DrawCurlyLine = [&](const auto x, const auto y, const auto cCurlyLines) {
        const auto curlyLineWidth = fontWidth;
        const auto curlyLineHalfWidth = std::lround(curlyLineWidth / 2.0f);
        const auto controlPointHeight = std::lround(3.5f * _lineMetrics.curlylinePeakHeight);

        // Each curlyLine requires 3 `POINT`s
        const auto cPoints = gsl::narrow<DWORD>(3 * cCurlyLines);
        std::vector<POINT> points;
        points.reserve(cPoints);

        const auto end = x + gsl::narrow_cast<til::CoordType>(cCurlyLines * curlyLineWidth);
        auto start = x;
        while (start < end)
        {
            points.emplace_back(start + curlyLineHalfWidth, y - controlPointHeight);
            points.emplace_back(start + curlyLineHalfWidth, y + controlPointHeight);
            points.emplace_back(start + curlyLineWidth, y);
            start += curlyLineWidth;
        }

        RETURN_HR_IF(E_FAIL, !MoveToEx(_hdcMemoryContext, x, y, nullptr));
        RETURN_HR_IF(E_FAIL, !PolyBezierTo(_hdcMemoryContext, points.data(), cPoints));
        return S_OK;
    };

    if (lines.test(GridLines::Left))

Review comment (suggestion):
BTW no that I see this, it may make sense to not use `auto` here, but rather explicit types. That way we ensure that we don't get multiple template instantiations.

Code after:
{
    LOG_IF_FAILED(_FlushBufferLines());

    // Convert the target from characters to pixels.
    const auto ptTarget = coordTarget * _GetFontSize();

    // Create a brush with the gridline color, and apply it.
    wil::unique_hbrush hbr(CreateSolidBrush(gridlineColor));
    RETURN_HR_IF_NULL(E_FAIL, hbr.get());
    const auto prevBrush = wil::SelectObject(_hdcMemoryContext, hbr.get());
    RETURN_HR_IF_NULL(E_FAIL, prevBrush.get());

    // Get the font size so we know the size of the rectangle lines we'll be inscribing.
    const auto fontWidth = _GetFontSize().width;
    const auto fontHeight = _GetFontSize().height;
    const auto widthOfAllCells = fontWidth * gsl::narrow_cast<unsigned>(cchLine);

    const auto DrawLine = [=](const auto x, const auto y, const auto w, const auto h) {
        return PatBlt(_hdcMemoryContext, x, y, w, h, PATCOPY);
    };
    const auto DrawStrokedLine = [&](const til::CoordType x, const til::CoordType y, const unsigned w) {
        RETURN_HR_IF(E_FAIL, !MoveToEx(_hdcMemoryContext, x, y, nullptr));
        RETURN_HR_IF(E_FAIL, !LineTo(_hdcMemoryContext, gsl::narrow_cast<int>(x + w), y));
        return S_OK;
    };
    const auto DrawCurlyLine = [&](const til::CoordType x, const til::CoordType y, const size_t cCurlyLines) {
        const auto curlyLineWidth = fontWidth;
        const auto curlyLineHalfWidth = std::lround(curlyLineWidth / 2.0f);
        const auto controlPointHeight = std::lround(3.5f * _lineMetrics.curlylinePeakHeight);

        // Each curlyLine requires 3 `POINT`s
        const auto cPoints = gsl::narrow<DWORD>(3 * cCurlyLines);
        std::vector<POINT> points;
        points.reserve(cPoints);

        auto start = x;
        for (size_t i = 0; i < cCurlyLines; i++)
        {
            points.emplace_back(start + curlyLineHalfWidth, y - controlPointHeight);
            points.emplace_back(start + curlyLineHalfWidth, y + controlPointHeight);
            points.emplace_back(start + curlyLineWidth, y);
            start += curlyLineWidth;
        }

        RETURN_HR_IF(E_FAIL, !MoveToEx(_hdcMemoryContext, x, y, nullptr));
        RETURN_HR_IF(E_FAIL, !PolyBezierTo(_hdcMemoryContext, points.data(), cPoints));
        return S_OK;
    };

    if (lines.test(GridLines::Left))
    {