UNPKG

codebridge-ai

Version:

Complete fullstack AI coding platform with AST-based code integration and local LLM support. Now with comprehensive web technology support (HTML/CSS/JS) plus JavaScript, Python, Rust, and C++.

20 lines 1.48 kB
{ "timestamp": "2025-08-02T14:34:57.733Z", "model": "starcoder2:3b", "language": "cpp", "scenario": "memory-safety", "task": "Add destructor, copy constructor, and move semantics", "originalCode": "class Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) {\n data = new char[s];\n size = s;\n }\n};", "rawResponse": "\n\n## Solution\n\n```cpp\nclass Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) : data{new char[s]}, size{s} {}\n\n ~Buffer() {\n delete[] data;\n }\n\n // Copy constructor\n Buffer(const Buffer& other) = default;\n\n // Move constructor\n Buffer(Buffer&& other) noexcept \n : data{other.data}, \n size{other.size} \n {\n other.data = nullptr;\n other.size = 0;\n }\n};\n```\n", "improvedCode": "class Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) : data{new char[s]}, size{s} {}\n\n ~Buffer() {\n delete[] data;\n }\n\n // Copy constructor\n Buffer(const Buffer& other) = default;\n\n // Move constructor\n Buffer(Buffer&& other) noexcept \n : data{other.data}, \n size{other.size} \n {\n other.data = nullptr;\n other.size = 0;\n }\n};", "duration": 1432, "success": false, "qualityMetrics": { "hasCode": true, "hasDestructor": true, "score": 0.3846153846153846, "rawScore": 0.5, "maxScore": 1.3 }, "error": null }