Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

stl

A proper way to create a matrix in c++

Note that also you can use boost.ublas for matrix creation and manipulation and also boost.graph to represent and manipulate graphs in a number of ways, as well as using algorithms on them, etc. Edit: Anyway, doing a range-check version of a vector for your purposes is not a hard thing: Note that you would also need to add the … Read more

Categories data structures Tags c++, data-structures, graph, matrix, stl

A proper way to create a matrix in c++

I want to create an adjacency matrix for a graph. Since I read it is not safe to use arrays of the form matrix[x][y] because they don’t check for range, I decided to use the vector template class of the stl. All I need to store in the matrix are boolean values. So my question is, if … Read more

Categories C++ Tags c++, data-structures, graph, matrix, stl

How do I reverse a C++ vector?

There’s a function std::reverse in the algorithm header for this purpose.

Categories C++ Tags c++, std, stl, vector

Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]

Your second example does not work if you send the argument by reference. Did you mean That would work, but an easier way is

Categories C++ Tags algorithm, c++, stl, vector

How do I erase an element from std::vector<> by index?

To delete a single element, you could do: Or, to delete more than one element at once:

Categories C++ Tags c++, erase, stl, vector

C++ Double Address Operator? (&&)

This is C++11 code. In C++11, the && token can be used to mean an “rvalue reference”.

Categories stl Tags c++, memory-address, operator-keyword, stl

What is the easiest way to initialize a std::vector with hardcoded elements?

One method would be to use the array to initialize the vector

Categories C++ Tags c++, initialization, stl, vector
Newer posts
← Previous Page1 … Page3 Page4
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress