Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>EDIT: boost::any using bcp (thanks AraK) seems to be the best solution to date but is it possible to prove (to some extent) that there exists no ANSI C++ solution to this problem?</p> </blockquote> <p>You seem a bit confused about the terminology here.</p> <p>First, let's call it ISO C++, shall we? It was standardized by ISO in 1998, and since then, that is what people have referred to when talking about "standard C++". Now, what do you mean by an "ANSI C++ solution"?</p> <ul> <li>A solution that compiles cleanly using only ANSI (or ISO) C++? If so, Boost <em>is</em> the ANSI C++ solution</li> <li>A solution <em>already implemented</em> in the ANSI C++ standard library? If so then no, no such solution exists (and there is no "proof", other than "go read through the language standard and see if you can find such a class. If you can't, it isn't there".</li> <li>A solution you could implement <em>yourself</em> using only ANSI C++. Then the answer is "yes, you could go copy the source code from Boost".</li> </ul> <p>I can't imagine what kind of "proof" you'd be looking for. C++ is a document in prose form. It is not a mathematical equation. It can not be "proven", except by saying "go read the standard". Proving that something <em>is</em> defined in the language or in the standard library is easy -- simply point out where in the standard it is described. But proving that something <em>isn't</em> there is basically impossible -- except by enumerating <em>every</em> single sentence of the standard, and document that none of them describe what you're looking for. And I doubt you'll find anyone willing to do <em>that</em> for you.</p> <p>Anyway, the correct standard C++ solution <em>is</em> to use Boost. It is not a heavy-weight solution. Boost is pretty lightweight in that you can include <em>exactly</em> the bits you need, with no dependencies on the rest of the library collection.</p> <p>From what you've described (a light application for a broad user base), there is zero reason not to use Boost. It can simplify your code and reduce the number of bugs caused by attempting to reinvent the wheel. When distributing the compiled executable, it has zero cost. The <code>Boost.Any</code> library is, like much of Boost, header-only, and is simply compiled into your executable. No separate libraries have to be distributed.</p> <p>There is nothing to be gained by trying to reinvent the wheel. Your executable will be no smaller or more efficient, but it <em>will</em> be more buggy.</p> <p>And I'm willing to bet that your home-brewed solution will <em>not</em> be ANSI C++. It will rely on some form of undefined behavior. If you want an ANSI-C++ solution, your best bet is Boost.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload