Note that there are some explanatory texts on larger screens.

plurals
  1. POTerm not evaluated to a function in C++
    primarykey
    data
    text
    <p>I have following code, which i taken from Boost and simplified for my project. Please accept my aplogies for pasting complete code, i done it so that it will be easy to answer my question. While compiling following code in VS 2008 i am getting followoing error.</p> <pre><code>error C2064: term does not evaluate to a function taking 3 arguments </code></pre> <p>I am expecting addOptions retruns OptionsInit object which call function operator with three arguments but that is not happening, can any one please find bug. Thanks in advance.</p> <pre><code>namespace MyInfrastructure { namespace Internal { class OptionDescrp; class OptionsInit; } class OptionsCollection { public: OptionsCollection(std::string optCollName); Internal::OptionsInit addOptions(); private: // avoid copying and assignment. // Prohibit copy OptionsCollection( const OptionsCollection&amp; ); OptionsCollection&amp; operator = (const OptionsCollection&amp; ); void add(Internal::OptionDescrp* desc) {m_options.push_back(desc);} std::vector&lt;Internal::OptionDescrp* &gt; m_options; std::string m_optCollName; friend class Internal::OptionsInit; }; } //////////// #include &lt;string&gt; #include &lt;vector&gt; #include &lt;assert.h&gt; #include "PrgmOptions.h" namespace MyInfrastructure { namespace Internal { class OptionDescrp { public: OptionDescrp(std::string pcOptname, std::string description, bool isOptValueReq); virtual ~OptionDescrp(){ }; private: std::string m_shortName; // option short name. std::string m_longName; // option long name. std::string m_description;// option description. }; class OptionsInit { public: OptionsInit(OptionsCollection* coll){ owner = coll; } OptionsInit&amp; operator()(std::string name, std::string description, bool isOptValReq); private: OptionsCollection* owner; }; } ///// namespace MyInfrastructure { OptionsCollection::OptionsCollection(std::string optCollName) : m_optCollName(optCollName) {} Internal::OptionsInit OptionsCollection::addOptions() { return Internal::OptionsInit(this); } } namespace MyInfrastructure { namespace Internal { // Class Options description definitions. OptionDescrp::OptionDescrp(std::string pcOptname, std::string description, bool isOptValueReq) : m_description(description) { std::string name(pcOptname); std::string::size_type n = name.find(','); if (n != std::string::npos) { assert(n == name.size()-2); m_longName = name.substr(0, n); m_shortName = '-' + name.substr(n+1,1); } else { m_longName = name; } } // Class Options Init definitions. OptionsInit&amp; OptionsInit::operator()(std::string name, std::string description, bool isOptValReq) { OptionDescrp* opt = new OptionDescrp(name, description, isOptValReq); owner-&gt;add(opt); return *this; } } } ////// int main(void) { MyInfrastructure::OptionsCollection desc("myoptions"); **desc.addOptions()("help", "produce help message", false); // error is thrown here** return 0; } </code></pre>
    singulars
    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.
 

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