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

  • SEARCH
  • Home
  • 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 6858961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:13:29+00:00 2026-05-27T02:13:29+00:00

I ran into some trouble while using a list of arrays. So to clear

  • 0

I ran into some trouble while using a list of arrays.
So to clear things up I do know that I can’t have a std::list containing arrays.
I am using boost::array to be able to do that.

Currently I prototype all datatypes needed for my pathfinding algorithm and test them for speed and cache coherence.

typedef boost::array<int,2> VertexB2i;
typedef std::list<VertexB2i> VertexList;

These types are not used for pathfinding, they are simply easier to use then all the real c++ arrays and flags for the pathfinder, so they are just used to generate a navigation mesh.
(I also know I could use a stl::pair instead boost::array in this case, but I want to keep the generated data as similar to the pathfinders data as possible, so I don’t have to deal with two totally different interfaces the whole time)

VertexList* vl = new VertexList();
vl->push_back({{8,28}}); // this does not work, why?

So while setting up some testing data for these two data-types, I noticed that the commented line does not work, although this does work:

VertexList* vl = new VertexList();
VertexB2i ver1 = {{8,28}};
vl->push_back({ver1}); // works

So to sum it up:
Is there anyway to pushback a “VertexB2i” without declaring it separte first?
General advices?

  • 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-05-27T02:13:30+00:00Added an answer on May 27, 2026 at 2:13 am

    std::array (or boost::array) is an aggregate type. In C++98/03 it can only be initialized in the declarator:

    std::array<int, 2> arr = { 1, 2 };
    thelist.push_back(arr); // makes a copy
    

    In C++11, you can use uniform initialization to create temporaries as well:

    std::list<std::array<int,2>> l;
    
    l.push_back(std::array<int,2>{{2,3}});     // maybe copy
    l.emplace_back(std::array<int,2>{{2,3}});  // maybe copy, probably optimized out
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While creating an online shop application using play-1.2.4 ,I ran into some problems with
While working on a mapping structure for our applications we ran into some trouble
I'm new to jsp and have ran into some trouble. Initially, the jsp file
I just ran into some code that overuse semicolons, or use semicolon for different
(this is regarding the Ramaze.net framework) I ran into some really strange problems while
It's been a while since I got into QCL but I ran into some
Ran into this error message while trying to select some records off a table.
I was doing some performance metrics and I ran into something that seems quite
I'm writing my own software rasterizer in Java, and I ran into some trouble
I am having trouble while using the YUI panel as a dialog. I have

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.