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 8896365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:01:40+00:00 2026-06-15T00:01:40+00:00

I wrote a MPC controller in C++, which included a Matrix class, where I

  • 0

I wrote a MPC controller in C++, which included a Matrix class, where I stored the data in an array and I used C memory functions(memcpy, memset etc). Today I replaced the array with c++ vector and I used copy to move the memory etc… I faced one problem, by replacing the array with vector the calculation time of the control signal almost doubled by using vector.

Is there any disadvantages if I’m using alloc,memcpy,memset, free ins c++ code? If there is any what are those?

  • 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-15T00:01:42+00:00Added an answer on June 15, 2026 at 12:01 am

    Vector adds value in 2 aspects:

    1. Provides additional functionality which is not present in C array, such as resizing, checking for current size etc. You may find better alternatives from its interface to your custom solution.
    2. Catches some bugs, such as addressing an address beyond the scope of the vector.

    If you are satisfied with your proprietary data management and confident in quality of your code, you don’t need vector. Note, though, this might pose some software issues, such as decreased maintainability of C array compared to vector (e.g., future code may access an out of bounds value, even if your current code doesn’t).

    Edit:
    See @Als answer for a possible alternative in your case (std::array).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a small sparse matrix class with the member: std::map<int,std::map<int,double> > sm; The
I wrote a symfony task to fill a database of sample data. Here's a
I wrote a PHP script that retrieves values from a MySQL Query. I used
I wrote a small script which copies the billing address to the delivery address
I wrote the sentence as follows: allLinkValues = ie.getLinksValue('class') but the return values are
I wrote a util class to filter elements in java.util.Collection as follows: public class
I wrote Front Controller Pattern and ran the test. Somehow request.getPathInfo() is returning null
I wrote this code which is working but it made me start thinking how
I wrote this code to scrape a sparse array from a series of dom
I wrote a makefile which behaves oddly. You can find it here: http://pastebit.com/pastie/8215 Basically

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.