Table of Contents

CPP Call-by-Value

Passing a copy of an argument to the called function. The semantics of function call is to pass a copy of an argument. The copy operation is defined by the argument type's copy constructor. See Also: call-by-reference. TC plus plus PL | TC++PL 7.2. (BSCppG 2012)

See also: CPP Call-by-Reference

CPP call-by-value is a method of passing arguments to functions where the function creates a local copy of the provided argument. This mechanism was introduced with the development of CPP in year 1983 and remains one of the most common ways to pass function parameters. Since a copy of the argument is created, modifications within the function do not affect the original variable.

In a CPP program, call-by-value is efficient for small data types like integers, floating-point numbers, and characters. These types occupy minimal memory and can be copied quickly, making the method ideal for lightweight calculations, data processing, and numerical functions.

When passing larger data types such as structures, classes, or containers, call-by-value can become memory-intensive due to the need to create a full copy. This results in increased memory usage and slower performance, especially in data-heavy applications like Kubernetes workload management or cloud-native APIs.

Developers should consider using call-by-value when the original data should remain unchanged. This prevents side effects, ensuring safer code and easier debugging. Additionally, call-by-value protects data integrity when working with sensitive information like API tokens, credentials, or application configuration files.

Move semantics, introduced in CPP11, optimize call-by-value by enabling functions to take advantage of temporary objects using `std::move()`. This allows functions to avoid deep copying when working with temporary data, reducing memory allocations and enhancing performance in high-throughput environments like Kubernetes API services.

Error handling in call-by-value is straightforward because the function operates on a local copy, reducing the chances of unintended modifications. This ensures that critical cloud components like Kubernetes Pods, Deployments, and Services remain isolated from changes during API request processing, enabling safer, type-safe application design.

Kubernetes-Specific Code Example:

```cpp

  1. include <iostream>
  2. include <string>

// Function demonstrating call-by-value void logPodStatus(std::string status) {

   std::cout << "Logging Pod status: " << status << "\n";
   status = "Terminated";  // This change affects only the local copy
}

// Function demonstrating call-by-reference for comparison void updatePodStatus(std::string& status) {

   status = "Running";  // This change affects the original variable
   std::cout << "Updated Pod status: " << status << "\n";
}

int main() {

   std::string podStatus = "Pending";
   std::cout << "Initial Pod status: " << podStatus << "\n";
   // Call-by-value: Does not change the original variable
   logPodStatus(podStatus);
   // Call-by-reference: Changes the original variable
   updatePodStatus(podStatus);
   std::cout << "Final Pod status: " << podStatus << "\n";
   return 0;
} ```

This example demonstrates CPP call-by-value in a Kubernetes context. The `logPodStatus` function creates a local copy of the `status` variable, leaving the original unchanged, while `updatePodStatus` modifies the original variable using call-by-reference. This approach highlights when to use call-by-value to ensure data safety and maintain application stability.

CPP Call-by-Value in Wasm

CPP call-by-value is crucial when developing WebAssembly (Wasm) modules, introduced in year 2017. In Wasm applications, arguments passed to functions are copied, ensuring that the original variables remain unchanged. This makes call-by-value ideal for isolated computations, numerical processing, and secure data handling in web-based environments.

When using CPP with Wasm, primitive types such as integers, floats, and booleans are passed by value efficiently due to Wasm's linear memory model. This helps reduce memory overhead and enables high-performance web applications like graphics rendering, data visualization, and real-time game engines.

Functions involving mathematical calculations or state-independent data transformations often use call-by-value to avoid side effects. This makes code safer and more predictable, especially when dealing with asynchronous WebAssembly tasks in modern browsers.

Pass-by-value in Wasm is commonly applied when working with immutable data structures or temporary variables generated during function execution. This ensures that complex operations like matrix calculations or cryptographic hashing do not affect the original data.

Emscripten, introduced in year 2013, facilitates CPP to Wasm compilation and supports call-by-value natively. Developers can pass arguments from JavaScript to Wasm modules, where values are copied, enabling type-safe interoperability between languages in full-stack web applications.

Error handling in Wasm-based applications benefits from call-by-value since function arguments are copied, preventing accidental overwriting of critical data. This ensures that security-sensitive web components like authentication services or financial calculators can operate safely in a Wasm runtime.

Wasm-Specific Code Example:

```cpp

  1. include <emscripten/bind.h>
  2. include <iostream>
  3. include <string>

// Function demonstrating call-by-value std::string formatGreeting(std::string name) {

   std::string greeting = "Hello, " + name + "!";
   name = "Guest";  // This change only affects the local copy
   return greeting;
}

// Function demonstrating call-by-reference for comparison void changeName(std::string& name) {

   name = "UpdatedUser";  // This change affects the original variable
}

// Wasm bindings EMSCRIPTEN_BINDINGS(wasm_module) {

   emscripten::function("formatGreeting", &formatGreeting);
   emscripten::function("changeName", &changeName);
}

int main() {

   std::string userName = "WasmUser";
   // Call-by-value: Does not change the original variable
   std::cout << formatGreeting(userName) << "\n";
   std::cout << "Original name after call-by-value: " << userName << "\n";
   // Call-by-reference: Changes the original variable
   changeName(userName);
   std::cout << "Name after call-by-reference: " << userName << "\n";
   return 0;
} ```

This example demonstrates CPP call-by-value in a Wasm application using Emscripten. The `formatGreeting` function uses call-by-value to keep the original variable unchanged, while `changeName` uses call-by-reference to modify the actual variable. This approach supports secure, efficient, and scalable web applications with predictable memory management.

CPP Call-by-Value in POCO Libraries for a Web Server

CPP call-by-value is widely used in building web servers with the POCO (Portable Components) libraries, introduced in year 2004. It simplifies passing HTTP request parameters, response headers, and service configurations to web server functions while ensuring that the original data remains unchanged. This approach is essential for scalable and secure web applications.

When processing HTTP requests in a CPP Web Server, call-by-value is useful when extracting request properties like URL parameters, query strings, or HTTP headers. The POCO library provides classes such as HTTPServerRequest and HTTPRequestHandler, enabling web servers to parse incoming requests without altering original data.

Functions that generate static responses or process lightweight data types such as request paths and query strings benefit from call-by-value. Since these strings are typically small, passing them by value ensures safer memory handling with minimal overhead.

Move semantics, introduced in CPP11, further optimize call-by-value by transferring ownership of temporary response objects. This allows developers to return large payloads efficiently when generating API responses or serving files from disk.

Pass-by-value also enhances error isolation. Since a function operating on a copied object cannot change the original request or response, potential bugs and security risks such as unauthorized data modification are minimized in multi-threaded web server environments.

Error handling is streamlined using POCO's built-in exception management. Web server functions can parse request data, handle form submissions, and generate responses safely while ensuring that no unintended side effects occur on the original request objects.

POCO Libraries CPP Web Server-Specific Code Example:

```cpp

  1. include “Poco/Net/HTTPServer.h”
  2. include “Poco/Net/HTTPRequestHandler.h”
  3. include “Poco/Net/HTTPRequestHandlerFactory.h”
  4. include “Poco/Net/HTTPServerParams.h”
  5. include “Poco/Net/ServerSocket.h”
  6. include “Poco/Util/ServerApplication.h”
  7. include <iostream>
  8. include <string>

using namespace Poco::Net; using namespace Poco::Util;

// Function demonstrating call-by-value void processRequest(std::string path) {

   std::cout << "Processing request for path: " << path << "\n";
   path = "/new-path";  // This change only affects the local copy
}

// Custom HTTP Request Handler class CustomRequestHandler : public HTTPRequestHandler { public:

   void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override {
       std::string requestPath = request.getURI();  // Call-by-value copy
       processRequest(requestPath);  // Original request remains unchanged
       response.setContentType("text/plain");
       std::ostream& out = response.send();
       out << "Request processed for: " << request.getURI() << "\n";
   }
};

// Custom Request Handler Factory class CustomRequestHandlerFactory : public HTTPRequestHandlerFactory { public:

   HTTPRequestHandler* createRequestHandler(const HTTPServerRequest&) override {
       return new CustomRequestHandler;
   }
};

// Web Server Application class WebServerApp : public ServerApplication { protected:

   int main(const std::vector&) override {
       ServerSocket serverSocket(8080);
       HTTPServer server(new CustomRequestHandlerFactory, serverSocket, new HTTPServerParams);
       server.start();
       std::cout << "Server running on port 8080...\n";
       waitForTerminationRequest();  // Wait for shutdown signal
       server.stop();
       return Application::EXIT_OK;
   }
};

int main(int argc, char** argv) {

   WebServerApp app;
   return app.run(argc, argv);
} ```

This example demonstrates CPP call-by-value in a POCO-based CPP Web Server. The `processRequest` function receives the request path by value, ensuring that any modifications remain local. This approach enhances web server stability and data integrity while supporting efficient memory management and scalable web API development.

CPP Call-by-Value in AWS SDK for CPP

CPP call-by-value is commonly used when working with the AWS SDK for CPP, introduced in year 2015. This SDK supports cloud services like Amazon S3, DynamoDB, and Amazon EC2. Using call-by-value helps developers process lightweight parameters like bucket names, access keys, and object keys without modifying the original data.

In cloud-based applications, API requests often require passing static values such as strings, configuration flags, or numeric identifiers. Call-by-value ensures these parameters remain unchanged, making the code safer and easier to debug. This is especially relevant when handling multiple concurrent requests where data integrity is critical.

Pass-by-value is appropriate when creating cloud service requests, where temporary objects like file names, service endpoints, and query parameters can be safely copied. Since these values are small, the memory overhead of copying them is minimal compared to using references.

Move semantics, introduced in CPP11, enhance call-by-value by enabling functions to transfer ownership of request payloads without creating deep copies. This technique optimizes memory usage when uploading large files or processing extensive API responses.

Cloud service failures can be managed using try-catch blocks. Developers can pass error codes or status messages by value to ensure safe error propagation without impacting the original objects or requests. This approach ensures that AWS SDK calls remain thread-safe and resilient to cloud service interruptions.

Memory management is simplified through shared_ptr and unique_ptr, enabling safe management of service clients and API response handlers. These constructs ensure that temporary data passed by value is securely managed throughout the application's lifecycle.

AWS SDK for CPP Specific Code Example:

```cpp

  1. include <aws/core/Aws.h>
  2. include <aws/s3/S3Client.h>
  3. include <aws/s3/model/PutObjectRequest.h>
  4. include <iostream>
  5. include <fstream>
  6. include <memory>

// Function demonstrating call-by-value void uploadFile(const Aws::S3::S3Client& client, std::string bucketName, std::string objectKey, std::string filePath) {

   Aws::S3::Model::PutObjectRequest request;
   request.SetBucket(bucketName.c_str());
   request.SetKey(objectKey.c_str());
   request.SetBody(std::make_shared(
       "uploadFile", filePath.c_str(), std::ios_base::in | std::ios_base::binary));
   auto outcome = client.PutObject(request);
   if (outcome.IsSuccess()) {
       std::cout << "File uploaded successfully to: " << bucketName << "/" << objectKey << "\n";
   } else {
       std::cerr << "Upload failed: " << outcome.GetError().GetMessage() << "\n";
   }
}

int main() {

   Aws::SDKOptions options;
   Aws::InitAPI(options);
   try {
       Aws::S3::S3Client client;
       // Call-by-value: Safe parameter passing for file upload
       uploadFile(client, "my-test-bucket", "uploaded-file.txt", "example.txt");
   } catch (const std::exception& ex) {
       std::cerr << "Error: " << ex.what() << "\n";
   }
   Aws::ShutdownAPI(options);
   return 0;
} ```

This example demonstrates CPP call-by-value using the AWS SDK for CPP. The `uploadFile` function receives cloud service parameters by value, ensuring the original data remains unchanged. This design supports scalable, memory-efficient cloud-based applications with robust error handling and data safety.

CPP Call-by-Value in Azure SDK for CPP

CPP call-by-value is widely used when working with the Azure SDK for CPP, introduced in year 2020. This SDK supports cloud services like Azure Blob Storage, Azure Key Vault, and Azure Service Bus. Using call-by-value ensures data safety by passing immutable copies of service names, container paths, and file names, preventing unexpected modifications during cloud operations.

When uploading files or retrieving secrets, functions often take parameters like connection strings, file paths, and blob names by value. This ensures that any changes within the function are isolated from the original variables, reducing bugs and enabling cleaner, more predictable cloud service interactions.

Pass-by-value is beneficial when passing lightweight data types such as file paths, configuration flags, and API endpoint URLs. Copying these types has minimal memory overhead, making them suitable for scalable cloud applications where multiple requests run concurrently.

Move semantics, introduced in CPP11, enhance cloud functions by transferring ownership of temporary request objects, reducing memory duplication when handling large file uploads or complex configuration payloads. This technique ensures optimal memory usage in resource-intensive cloud-native applications.

Error management in cloud-based applications benefits from call-by-value. Since request parameters are passed as independent copies, developers can safely propagate error messages, log service statuses, and retry failed requests without affecting the original request structure.

Memory management is simplified using shared_ptr and unique_ptr, ensuring temporary request objects are properly managed throughout API calls. This design pattern prevents memory leaks while supporting long-running cloud applications that handle large-scale file transfers or distributed jobs.

Azure SDK for CPP Specific Code Example:

```cpp

  1. include <azure/storage/blobs.hpp>
  2. include <iostream>
  3. include <fstream>
  4. include <memory>

using namespace Azure::Storage::Blobs;

// Function demonstrating call-by-value void uploadFile(BlobClient client, std::string containerName, std::string blobName, std::string filePath) {

   try {
       auto fileStream = std::make_shared(filePath, std::ios::binary);
       if (!fileStream->is_open()) {
           throw std::runtime_error("Failed to open file: " + filePath);
       }
       UploadBlockBlobOptions options;
       client.Upload(*fileStream, options);
       std::cout << "File uploaded successfully to: " << containerName << "/" << blobName << "\n";
   } catch (const std::exception& ex) {
       std::cerr << "Upload failed: " << ex.what() << "\n";
   }
}

int main() {

   auto client = BlobClient::CreateFromConnectionString(
       "DefaultEndpointsProtocol=https;AccountName=your_account_name;AccountKey=your_account_key",
       "my-container",
       "my-blob");
   // Call-by-value: Parameters safely copied for upload
   uploadFile(client, "my-container", "my-blob.txt", "example.txt");
   return 0;
} ```

This example demonstrates CPP call-by-value using the Azure SDK for CPP. The `uploadFile` function copies cloud service parameters by value, ensuring the original data remains unchanged. This design supports scalable cloud-based operations with robust memory management, error handling, and efficient cloud API integration.

CPP Call-by-Value in Google Cloud CPP Client Libraries

CPP call-by-value is commonly used when interacting with the Google Cloud CPP Client Libraries, introduced in year 2019. These libraries provide APIs for managing cloud services such as Google Cloud Storage, Google Pub/Sub, and Google Compute Engine. Using call-by-value ensures that parameters like bucket names, object keys, and project IDs remain unchanged during cloud operations.

Pass-by-value works well for lightweight data such as file names, resource identifiers, and query strings. Copying these values keeps the original data safe from unexpected modifications, making code easier to debug and secure in multi-threaded cloud-based applications.

Move semantics, introduced in CPP11, enhance the efficiency of call-by-value by allowing temporary request objects to be passed without copying. This reduces memory usage and improves performance, particularly when processing large payloads or data streams in cloud services like Google Cloud Storage.

Google Cloud CPP Client Libraries functions frequently process file uploads, metadata updates, and storage management requests. These operations use call-by-value for immutable properties like bucket names and file paths, ensuring the original request data stays intact.

Error handling is simplified through call-by-value because temporary objects can be safely discarded or reused in case of failures. This allows developers to wrap cloud API calls in try-catch blocks, ensuring robust and fault-tolerant cloud-native applications.

Memory management is streamlined through modern CPP constructs like shared_ptr and unique_ptr. These ensure that service clients and cloud request objects are securely managed, preventing memory leaks and supporting long-running cloud applications.

Google Cloud CPP Client Libraries Specific Code Example:

```cpp

  1. include <google/cloud/storage/client.h>
  2. include <iostream>
  3. include <memory>

using ::google::cloud::StatusOr; using ::google::cloud::storage::Client; using ::google::cloud::storage::ObjectMetadata;

// Function demonstrating call-by-value void uploadFile(Client client, std::string bucketName, std::string objectName, std::string filePath) {

   try {
       auto metadata = client.UploadFile(filePath, bucketName, objectName, google::cloud::storage::IfGenerationMatch(0));
       if (!metadata) {
           throw std::runtime_error("Upload failed: " + metadata.status().message());
       }
       std::cout << "File uploaded successfully to: " << metadata->bucket() << "/" << metadata->name() << "\n";
   } catch (const std::exception& ex) {
       std::cerr << "Error: " << ex.what() << "\n";
   }
}

int main() {

   auto client = Client::CreateDefaultClient().value();
   // Call-by-value: Passing safe, immutable parameters
   uploadFile(client, "my-test-bucket", "uploaded-file.txt", "example.txt");
   return 0;
} ```

This example demonstrates CPP call-by-value using the Google Cloud CPP Client Libraries. The `uploadFile` function receives parameters such as the storage client, bucket name, and file path by value, ensuring safe cloud API calls while maintaining application stability and robust memory management.

CPP Call-by-Value in Kubernetes Engine API CPP Client Library

CPP call-by-value is widely used when working with the Kubernetes Engine API CPP Client Library, hosted at https://googleapis.dev/cpp/google-cloud-container/latest. This library provides APIs for managing Kubernetes clusters, node pools, and deployments on Google Kubernetes Engine (GKE). Passing parameters by value ensures that request objects such as project IDs, cluster names, and resource configurations remain unchanged during Kubernetes operations.

Pass-by-value works well when dealing with lightweight parameters such as region names, Kubernetes cluster IDs, and project identifiers. Copying these values into API request functions prevents the original data from being altered, ensuring that cloud-native Kubernetes applications remain stable and secure.

Move semantics, introduced in CPP11, further enhance the efficiency of call-by-value in Kubernetes API requests. Functions can take temporary Kubernetes configuration objects by value and use `std::move()` to avoid memory duplication. This practice minimizes memory usage when deploying large workloads to the Kubernetes cluster.

Operations such as creating clusters, scaling deployments, and updating configurations typically involve immutable properties like zone names and cluster versions. These values are safely passed by value, ensuring error-free API calls and reducing the risk of unintended data modifications.

Error management is integrated into the API client library. Developers can use try-catch blocks to manage API request failures caused by invalid requests, insufficient permissions, or resource limitations, enabling fault-tolerant Kubernetes management applications.

Memory management is streamlined with shared_ptr and unique_ptr, ensuring that Kubernetes API request objects and client instances are securely managed, reducing memory leaks and supporting long-running cloud-based applications.

Kubernetes Engine API CPP Client Library Specific Code Example:

```cpp

  1. include <google/cloud/container/cluster_manager_client.h>
  2. include <iostream>
  3. include <memory>

using ::google::cloud::StatusOr; using ::google::cloud::container::ClusterManagerClient; using ::google::cloud::container::v1::Cluster;

// Function demonstrating call-by-value void createCluster(ClusterManagerClient client, std::string projectID, std::string location, std::string clusterName) {

   google::cloud::container::v1::CreateClusterRequest request;
   request.set_parent("projects/" + projectID + "/locations/" + location);
   auto* cluster = request.mutable_cluster();
   cluster->set_name(clusterName);
   cluster->set_initial_node_count(3);
   try {
       StatusOr response = client.CreateCluster(request);
       if (!response) {
           throw std::runtime_error("Cluster creation failed: " + response.status().message());
       }
       std::cout << "Cluster " << response->name() << " created successfully.\n";
   } catch (const std::exception& ex) {
       std::cerr << "Error: " << ex.what() << "\n";
   }
}

int main() {

   auto client = ClusterManagerClient::CreateDefaultClient().value();
   // Call-by-value: Passing Kubernetes API parameters safely
   createCluster(client, "my-kubernetes-project", "us-central1", "my-gke-cluster");
   return 0;
} ```

This example demonstrates CPP call-by-value using the Kubernetes Engine API CPP Client Library, hosted at https://googleapis.dev/cpp/google-cloud-container/latest. The `createCluster` function safely copies its parameters, ensuring that project and cluster details remain unchanged during Kubernetes API calls. This design supports scalable Kubernetes management while providing robust memory and error management.

CPP Call-by-Value in HashiCorp Vault

CPP call-by-value is critical when working with HashiCorp Vault using the CPP library for Hashicorp Vault libvault, hosted at https://github.com/abedra/libvault. This library allows secure interactions with Vault’s API for secrets management, making call-by-value suitable for passing sensitive information like tokens, API keys, and secret paths.

Pass-by-value works well when passing temporary Vault-related strings such as Vault paths, access tokens, and secret keys. Since these values are often immutable, copying them into functions ensures that sensitive data remains unchanged, reducing potential security risks.

Move semantics, introduced in CPP11, optimize call-by-value by transferring ownership of temporary secrets, configuration payloads, or API responses using `std::move()`. This prevents costly deep copies during sensitive operations like secret creation or key management.

Error handling is seamlessly integrated using try-catch blocks. If a secret retrieval or token generation request fails, the error message can be safely passed by value for logging or alert generation, ensuring that sensitive values remain protected.

Since Vault clients manage critical secrets, securely managing memory through shared_ptr and unique_ptr prevents memory leaks while ensuring that secret payloads are properly destroyed after use. This supports long-running cloud-native applications requiring continuous secrets management.

Passing API request details by value ensures that dynamic values like service account credentials or Vault roles remain isolated from external changes, enhancing cloud-native security in multi-threaded applications that access Vault concurrently.

HashiCorp Vault Specific Code Example:

```cpp

  1. include <iostream>
  2. include <memory>
  3. include <vault/client.h>
  4. include <vault/config.h>

using namespace Vault;

// Function demonstrating call-by-value void retrieveSecret(Client client, std::string path, std::string key) {

   try {
       auto response = client.read(path);
       if (response.data.find(key) != response.data.end()) {
           std::cout << "Retrieved secret: " << response.data.at(key) << "\n";
       } else {
           throw std::runtime_error("Secret key not found.");
       }
   } catch (const std::exception& ex) {
       std::cerr << "Error: " << ex.what() << "\n";
   }
}

int main() {

   Config config;
   config.address = "http://127.0.0.1:8200";  // Vault server address
   config.token = "my-root-token";            // Root token for simplicity
   // Initialize Vault client
   Client client(config);
   // Call-by-value secret retrieval
   retrieveSecret(client, "secret/data/myapp/config", "database_password");
   return 0;
} ```

This example demonstrates CPP call-by-value using the CPP library for Hashicorp Vault libvault, hosted at https://github.com/abedra/libvault. The `retrieveSecret` function securely passes client credentials, secret paths, and keys by value, ensuring safe memory management while preventing data leaks in cloud-native secrets management applications.

CPP Call-by-Value in CPP DevOps CLI Automation Using CLIUtils CLI11

CPP call-by-value is essential when building DevOps automation tools using CLIUtils CLI11, hosted at https://github.com/CLIUtils/CLI11. This method ensures that command-line arguments like service names, file paths, and retry counts are passed as independent copies, protecting original data from unintended changes during task execution.

Pass-by-value is commonly used when defining CLI commands and parsing configuration options. Strings like project names, deployment regions, and environment variables are frequently copied into parsing functions, ensuring thread safety and error isolation.

When processing large argument sets or dynamically created tasks, passing values avoids memory management complexities related to mutable references. This makes CLIUtils CLI11 ideal for building DevOps CLI tools for continuous integration, deployment automation, and cloud resource management.

Move semantics, introduced in CPP11, further optimize call-by-value by transferring ownership of temporary argument containers and task definitions. This approach minimizes memory usage, allowing CLI applications to run efficiently in resource-constrained environments.

Error handling is tightly integrated using CLI11’s built-in validation framework. Developers can define required options, default values, and validation rules that automatically raise descriptive errors if arguments are invalid, enabling robust CLI-driven DevOps automation workflows.

Memory management is simplified using shared_ptr and unique_ptr, ensuring that dynamically allocated argument sets, task managers, and configuration objects are safely managed without the risk of memory leaks in long-running CLI automation tools.

CPP DevOps CLI automation CLIUtils CLI11 Specific Code Example:

```cpp

  1. include <CLI/CLI.hpp>
  2. include <iostream>
  3. include <string>

// Function demonstrating call-by-value void executeDeploy(std::string serviceName, int retryCount) {

   std::cout << "Deploying service: " << serviceName << "\n";
   for (int i = 0; i < retryCount; ++i) {
       std::cout << "Retry attempt " << i + 1 << "...\n";
   }
   std::cout << "Deployment completed.\n";
}

int main(int argc, char** argv) {

   CLI::App app{"DevOps CLI Automation Tool"};
   std::string serviceName;
   int retryCount = 3;
   // Define CLI options using call-by-value
   app.add_option("-s,--service", serviceName, "Service name to deploy")->required();
   app.add_option("-r,--retry", retryCount, "Number of retry attempts")->default_val("3");
   try {
       CLI11_PARSE(app, argc, argv);
       // Call-by-value task execution
       executeDeploy(serviceName, retryCount);
   } catch (const std::exception& ex) {
       std::cerr << "Error: " << ex.what() << "\n";
   }
   return 0;
} ```

This example demonstrates CPP call-by-value in CPP DevOps CLI automation using CLIUtils CLI11, hosted at https://github.com/CLIUtils/CLI11. The `executeDeploy` function passes both the service name and retry count by value, ensuring that the original arguments remain unchanged during CLI parsing and task execution. This design supports scalable DevOps automation with safe memory management and robust error handling.