Encapsulating Data Outside of a Class
<p>I'm writing some C++ functions that will produce data that may or may not be processed later by those functions (but will not be processed anywhere else). These functions are the 'low-level' for some higher-level, GUI changes.</p>

<p>I'm currently wrapping these functions in a separate namespace, and have declared a static (internally linked) vector to contain these objects within the vector (the objects are defined as a struct, also contained within the namespace). Thus, the general structure:</p>

<pre><code>namespace Foo
{
    struct Bar
    {
        string data;
    };

    void func1();
    void func2();
    static std::vector&lt;Bar&gt; cachedBars;
}
</code></pre>

<p>I really don't need a class for this, and am not interested in resorting to a singleton. Is this solution sufficient? Specifically, is internally-linking a namespace-scope collection the best way to restrict access to that collection, as well as avoiding all of the pitfalls of global variables, or is there a better way?</p>
