Ice for C++

Ice for C++ supplies the raw power required by performance-hungry distributed systems, without forcing users to struggle with an arcane API. The Ice language mapping for C++ enables programmers to be immediately productive and reduces development and maintenance costs by eliminating the need for explicit memory management. Productivity is further enhanced by using the C++ Standard Library for data types, and the availability of a wide variety of useful tools and services including documentation, security, deployment, and database integration. All Ice language mappings are fully interoperable.


Programmers will instantly appreciate the productivity offered by the elegant C++ language mapping, which was carefully designed from the ground up to be easy to learn and just as easy to use. For example, one aspect of C++ development that is a continual source of trouble for programmers is memory management. Ice for C++ avoids the potential issues caused by explicit memory management with the help of smart pointers: the Ice API never requires the programmer to explicitly delete memory or modify the reference count of an object. Furthermore, applications that create graphs of Ice objects can enable automatic garbage collection to prevent memory leaks due to cyclic references.

Another example of the many ways in which Ice for C++ enhances programmer productivity is its use of the C++ Standard Library. Already familiar to most C++ programmers, the Standard Library is a powerful generic framework that is widely supported and offers a wealth of standard data types and algorithms. The C++ language mapping for Ice uses the Standard Library to represent sequence and dictionary types, leveraging the programmer's experience with the library to minimize the learning curve and support all of the flexibility the library has to offer.


Although the C++ language mapping emphasizes simplicity and productivity, it does not sacrifice performance to achieve them. The Ice architecture is designed to minimize data copying and other sources of overhead to ensure that Ice rivals or exceeds the performance of any other general-purpose distributed computing technology.


Ice for C++ supports many of the most common compilers and platforms used for distributed application development. Furthermore, the high-quality source code is freely available for users that are interested in porting Ice to environments that are not currently supported. Ice for C++ enhances the portability of Ice applications by providing robust and well-documented interfaces for common platform-specific chores such as threading and synchronization. Since Ice uses these interfaces internally, they are thoroughly tested and address the functional requirements of most applications.

Sample Code

To illustrate how Ice is used with C++, consider the following Slice interface definitions:

module Biz {
    struct Item {
        string sku;
        int qty;
    sequence<Item> ItemSeq;
    interface Invoice {
        void addItems(ItemSeq items);
        void submit();
    interface InvoiceFactory {
        Invoice* create();

C++ code that creates an invoice using the factory is shown below:

// Create a proxy for the invoice factory object.
Ice::ObjectPrx proxy = communicator->stringToProxy("InvoiceFactory:tcp -p 9000");

// Narrow the proxy to the proper type.
Biz::InvoiceFactoryPrx factory = Biz::InvoiceFactoryPrx::checkedCast(proxy);

// Use the factory to obtain a proxy for a new invoice object.
Biz::InvoicePrx invoice = factory->create();

// Add items to the invoice.
Biz::ItemSeq items;
Biz::Item item;
item.sku = "10-6139";
item.qty = 3;

// Submit the invoice.
Terms of Use | Privacy | Software License © 2015 ZeroC, Inc.