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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:40:52+00:00 2026-05-11T17:40:52+00:00

In an attempt to wrap some unmanaged code in a managed .dll I’m trying

  • 0

In an attempt to wrap some unmanaged code in a managed .dll I’m trying to convert a Generic::List of data points into a std::vector. Here’s a snippet of what I’m trying to do:

namespace ManagedDLL
{
    public ref class CppClass
    {
        void ListToStdVec( const List<double>& input_list, std::vector<double>& output_vector )
        {
            // Copy the contents of the input list into the vector
            // ...
        }

        void ProcessData( List<double> sampleData )
        {
            std::vector<double> myVec;

            ListToStdVec( sampleData, myVec );

            // Now call the unmanaged code with the new vector
            // ...
        }
    }
}

Compiling this gives me:

error C3699: ‘&’ : cannot use this indirection on type ‘const System::Collections::Generic::List’

I’ve probably missed something fundamental here (I’m relatively new to .net’s way of doing things), but that looks like reasonably valid code to me.. ?

[Edit] I’ve tried both Andy and Dario’s suggestions and they work, but how do I then access the members of the input list? I’ve tried all sorts of combinations of dreferencing and nothing seems to compile:

void ListToStdVec( const List<double>% input_list, std::vector<double>& output_vector )
{
    int num_of_elements = input_list->Count;
}

void ListToStdVec( const List<double>^ input_list, std::vector<double>& output_vector )
{
    int num_of_elements = input_list.Count;
}

…both give me:

error C2662: ‘System::Collections::Generic::List::Count::get’ : cannot convert ‘this’ pointer from ‘const System::Collections::Generic::List’ to ‘System::Collections::Generic::List %’

…so how do you access the reference / pointer?

  • 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-11T17:40:52+00:00Added an answer on May 11, 2026 at 5:40 pm

    As List<T> is a managed .NET class, it’s passed by managed GC-Handle denoted by ^ and not by C++-reference.

    Ex:

    void ListToVec(List<double>^ input_list, std::vector<double>& out)
    

    You don’t need additional const here. The notation List<T>^% creates a tracking reference (comparable to C++-pointers) rather than a call by reference.
    Just access the members by list->... and list[...].

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

Sidebar

Related Questions

In an attempt to add some parameter validation and correct usage semantics to our
Has there been any attempt and creating a formalized method for organizing CSS code?
For some reason when I attempt to make a request to an Ajax.net web
I am using the following code to attempt to read a large file (280Mb)
I'm using jqGrid to display some data on a page. Within the controller action,
Here is my attempt, xsd and classes created from xsd.exe Running my code I
I started to play with a OpenGL ES 1.0 and I run into some
If I attempt to connect to Mac OS X 10.5 Leopard's built in vnc
When you attempt to declare an unsigned variable in C#.NET with a value outside
I've decided to attempt using the double submitted cookies technique to attempt to prevent

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.