Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 12, 2025

Summary

This PR addresses issue #23 by providing a script that automatically converts auto variable declarations to static constexpr for $break, $continue, and any variables in C++ codebases.

Changes Made

  • ✅ Created make_constexpr.sh - A robust script that processes C++ files and converts specific variable patterns
  • ✅ Added comprehensive documentation in README_make_constexpr.md
  • ✅ Included test files demonstrating the conversion patterns
  • ✅ Verified functionality with sample C++ code

Supported Conversions

The script converts these patterns:

  • auto $break = Constants.Break;static constexpr auto $break = Constants.Break;
  • auto $continue = Constants.Continue;static constexpr auto $continue = Constants.Continue;
  • auto any = Constants.Any;static constexpr auto any = Constants.Any;
  • auto $break {Constants.Break};static constexpr auto $break {Constants.Break};
  • auto $continue {Constants.Continue};static constexpr auto $continue {Constants.Continue};
  • auto any {Constants.Any};static constexpr auto any {Constants.Any};

Usage

# Process current directory
./make_constexpr.sh

# Process specific directory  
./make_constexpr.sh /path/to/cpp/project

Safety Features

  • Only modifies exact pattern matches to avoid unintended changes
  • Preserves original indentation and formatting
  • Reports which files were modified
  • Safe to run multiple times (idempotent)

Test Results

Tested on sample files with various patterns - all conversions work correctly while preserving other auto declarations.

🤖 Generated with Claude Code


Resolves #23

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #23
@konard konard self-assigned this Sep 12, 2025
- Created make_constexpr.sh script that converts auto variable declarations to static constexpr
- Supports both assignment (=) and brace initialization ({}) syntax
- Processes all C++ files (.h, .hpp, .cpp, .cc) in specified directory
- Only modifies specific patterns matching Constants.Break, Constants.Continue, Constants.Any
- Includes test files and documentation
- Addresses issue #23 for improved C++ code optimization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Run script to make all , , variables constexpr Add script to make $break, $continue, $any variables constexpr Sep 12, 2025
@konard konard marked this pull request as ready for review September 12, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run script to make all $break, $continue, $any variables constexpr

2 participants