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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:00:12+00:00 2026-06-15T02:00:12+00:00

In C++/CLI, you can specify the following for multidimensional arrays. array<int, 2>^ Foo =

  • 0

In C++/CLI, you can specify the following for multidimensional arrays.

array<int, 2>^ Foo = gcnew array<int, 2>(10);
Foo[0, 0] = 1;
Foo[1, 0] = 2;
// ...

I’m trying to replicate the above in the closest syntax possible in standard C++ (C++11 is allowed) via a templated class called my_array.

e.g.

template <typename T, int rank = 1>
    class my_array { };

Is it possible via some comma operator overloading tricks to achieve C++/CLI’s syntax under standard C++, along with overriding my_array’s subscript operator?

Ideally, I’d like the my_array used this way (equivalent to the above example):

my_array<int, 2> Foo = // ... (ignore this part - already implemented)
Foo[0, 0] = 1;
Foo[1, 0] = 2;
// ...

In case anyone’s wondering, I’m creating a C++/CLI equivalent for GCC and currently the framework does not support multidimensional arrays. I’m looking to add that functionality in the closest possible way syntax wise to C++/CLI.

  • 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-15T02:00:14+00:00Added an answer on June 15, 2026 at 2:00 am

    No it is not possible in standard C++. Indeed operator[] can only take a single argument.

    You may achieve similar syntax using one of these solutions:

    • operator() with several arguments like array(i, j)
    • Use a proxy class for arguments, e.g. array[makeIndex(i, j)]
    • Using comma operator: array[makeIndex(i), makeIndex(j)]
    • Or array[IndexBegin, i, j].

    See also this and that questions.

    — Optimization note —

    In you go the comma route, you’ll be building dynamic lists with the comma operator, and the array will be checking the length of these lists. In a naive implementation these checks will be run-time and redundant (when used in a loop).

    Better option: use lists of statically known length (with templates) Like IndexBegin is IndexList<0>, IndexList<N> [comma] int is IndexList<N+1>. Then if your array also know its dimension statically, like a 2D array is Array<2> then you can check at compile time that a 2D array only accepts 2 indices.

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

Sidebar

Related Questions

I'm trying to create a very simple PHP CLI application that can be run
How can i convert interoperatability between a c++/CLI Array and a native c++ array
How can I give a CLI Option a type - such as int or
Just wondering is it possible to build CLI app that can be run from
Suppose I develop an application with the logic as a CLI program that can
Can the behaviour of pin_ptr be achieved directly in C++/CLI? For example, is it
I created a keyspace with the cassandra-cli tool, and i can use it. However
In VMware ESX/i, how can I use the VMware Virtual Infrastructure Remote CLI to
What are the benifits of using a value class in C++/CLI.Can the value class
Is there a CLI tool I can use to quickly view the transitive dependencies

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.