out_ptr

Repository: ThePhD/out_ptr

Support: Consider donating here.

out_ptr is a scalable output pointer abstraction for making it easier to put output pointer values into smart and fancy pointers such as std::unique_ptr, std::shared_ptr, boost::shared_ptr, and other upcoming smart pointers such as boost::local_shared_ptr and std::retain_ptr!

A fully rendered proposal for the full rationale of this library can be found through rawgit in the main repository page, and below there are links to sections of the full documentation.

It’s a small but useful library, so feel free to dive right on in! Finally, consider donating here to support my programming endeavors, Boost inquiries and standardization efforts!

Sneak Peak

Example Usage, given some C-Style API:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <some_c_api.h>

#include <phd/out_ptr.hpp>

int main (int, char*[]) {

        std::unique_ptr<int, resource_deleter> resource(nullptr);
        error_num err = c_api_create_handle(24, std::out_ptr(resource));
        if (err == C_API_ERROR_CONDITION) {
                // handle errors
        }
        // resource.get() the out-value from the C API function
        // ..

        return 0;
}

Dive In!