Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:10:19+00:00 2026-06-18T04:10:19+00:00

I have a struct OpDesc { std::string OPName; size_t OPArgsMin; bool IsVaribaleArgsNum; bool IsOPChange;

  • 0

I have a

struct OpDesc {
        std::string  OPName;
        size_t       OPArgsMin;
        bool         IsVaribaleArgsNum;
        bool         IsOPChange;
        std::string  ChangeNodeOP;
        std::string  ChangeNodeLabel;
        bool         IsOPDelete;
        const char*  ErrMsg;
    };

And want to init a std::map<string, OpDesc>.

I tried doing it this way :

typedef std::map<std::string,struct OpDesc> OpDescMap;
OpDescMap opDesc;
opDesc["StoreOp"] = {"StoreOp",2,false,false,"","",false,""};
/// etc.

I can’t compile that with VS10. I get : error C2059: syntax error : '{'

How can it be solved?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:10:20+00:00Added an answer on June 18, 2026 at 4:10 am

    Your syntax is valid C++11 (see Uniform Initialization), however, VS10 does not support it. It was only added to VS12 (see C++ features in VS2012). One option is to upgrade your compiler to one that has better conformance to C++11.

    If you can’t upgrade, you’ll have to fallback to C++03 syntax. You can either use an intermediate variable:

    OpDesc op = {"StoreOp", 2, false, false, "", "", false, ""};
    opDesc[op.OPName] = op;
    

    Or add a constructor to your structure:

    struct OpDesc {
       // ... all fields
       OpDesc(std::string const& opName, size_t opArgsMin, bool isVariableArgsNum,
              bool isOpChange, std::string const& changeNameOp,
              std::string const& changeNodeLabel, bool isOpDelete,
              char const* errMsg)
       : OPName(opName), OPArgsMin(opArgsMin), IsVariableArgsNum(isVariableArgsNum),
         IsOpChange(isOpChange), ChangeNameOp(changeNameOp),
         ChangeNodeLabel(changeNodeLabel), IsOpDelete(isOpDelete),
         ErrMsg(errMsg) {}
    };
    
    opDesc["StoreOp"] = OpDesc("StoreOp", 2, false, false, "", "", false, "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struct that looks something like: struct foo_t { template <std::size_t x,
Extends . I have: struct Coord { int row, col ; bool operator<( const
I have: struct DoubleVec { std::vector<double> data; }; DoubleVec operator+(const DoubleVec& lhs, const DoubleVec&
I have a struct, MyStruct , that has a private member private bool[] boolArray;
I have: struct Mystruct { void Update(float Delta); } typedef std::map<int, Mystruct*> TheMap; typedef
Suppose I have: struct Vehicle {...} struct Car : public Vehicle {...} string A(Vehicle
Let's say I have struct Value { int foo(); }; size_t *begin = ...,
Ok so I have struct like this typedef struct { float x; float y;
Suppose I have: struct Magic { Magic(Foo* foo); Magic(Bar* bar); }; Is there a
using C++, I have struct Base { virtual void stuff(/*base stuff*/); }; struct Derived

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.