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 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

Ask A Question

Stats

  • Questions 193k
  • Answers 193k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this rule: RewriteCond $1 !.*\.aspx$ RewriteRule (.*) $1.aspx [L]… May 12, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer Ok from what I remember with the ISession.CreateQuery you can… May 12, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer For controls with the AutoScroll property try the HorizontalScroll and… May 12, 2026 at 6:29 pm

Related Questions

In an attempt to wrap some unmanaged code in a managed .dll I'm trying
In a managed wrapper over a native library, I have to accomplish certain operations
Using jQuery, how do I delete all rows in a table except the first?
I'm a modest graduate student in a high energy particle physics department. With an
I am working on a program that uses Spring and obtains Hibernate transactions transparently

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.