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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:09:19+00:00 2026-06-12T15:09:19+00:00

I have a list of boost::tuple . I want to expose this tuple list

  • 0

I have a list of boost::tuple. I want to expose this tuple list to Java bindings through SWIG. But when I try to compile mt wrap.cxx, generated by SWIG, I get following errors:

d:\xyz\...\vector.h(115) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const boost::tuples::tuple<T0,T1>' (or there is no acceptable conversion)
        with
        [
            T0=std::string,
            T1=std::string
        ]
        c:\program files\microsoft visual studio 8\vc\platformsdk\include\guiddef.h(192): or 'int operator ==(const GUID &,const GUID &)'
        while trying to match the argument list '(const boost::tuples::tuple<T0,T1>, const MyTuple)'
        with
        [
            T0=std::string,
            T1=std::string
        ]
        d:\xyz\...\vector.h(111) : while compiling class template member function 'int Vector<T>::index(const T &) const'
        with
        [
            T=MyTuple
        ]
        d:\xyz\...\MyTuple_wrap.cxx(17731) : see reference to class template instantiation 'Vector<T>' being compiled
        with
        [
            T=MyTuple
        ]

Can anyone tell me what I should do to resolve this issue?

  • 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-12T15:09:20+00:00Added an answer on June 12, 2026 at 3:09 pm

    It is unclear how you arrived at the error you’ve shown. boost::tuple is tricky to wrap by default and there doesn’t seem to be any standard interface to it included with SWIG. In my tests I couldn’t get close to the error you were seeing without manually writing an interface file.

    I did however succeeded in wrapping boost’s tuples using the following interface file:

    %{
    #include <boost/tuple/tuple.hpp>
    %}
    
    namespace boost {
      template <typename T1=void, typename T2=void, typename T3=void> 
      struct tuple;
    
      template <>
      struct tuple<void,void,void> {
      };
    
      template <typename T1>
      struct tuple<T1, void, void> {
        tuple(T1);
        %extend {
          T1 first() const {
            return boost::get<0>(*$self);
          }
        }
      };
    
      template <typename T1, typename T2>
      struct tuple <T1, T2, void> {
        tuple(T1,T2);
        %extend {
          T1 first() const {
            return boost::get<0>(*$self);
          }
          T2 second() const { 
            return boost::get<1>(*$self);
          }
        }
      };
    
      template <typename T1, typename T2, typename T3> 
      struct tuple <T1,T2,T3> {
        tuple(T1,T2,T3);
        %extend {
          T1 first() const {
            return boost::get<0>(*$self);
          }
          T2 second() const {
            return boost::get<1>(*$self);
          }
          T3 third() const {
            return boost::get<2>(*$self);
          }
        }
      };
    }
    

    Basically all it does is add accessor functions to each of the specialisations of tuple you might care about. It’s sufficient to make it minimally useful in Java or some other language. You would want to expand on this to cover larger tuples. You probably want to make the member functions get/set if your tuples aren’t intended to be immutable.

    I was able to test this with a SWIG module:

    %module test
    
    %include "boost_tuple.i"
    
    %template(TestTuple) boost::tuple<int, double, char>;
    
    %template(SingleTuple) boost::tuple<char>;
    
    %inline %{
    boost::tuple<int, double, char> func1() {
      return boost::make_tuple(3, 2.0, '1');
    }
    
    void test1(boost::tuple<int, double, char>) {
    }
    
    %}
    

    Which worked as expected with the following Java:

    public class run {
      public static void main(String[] argv) {
        System.loadLibrary("test");
        TestTuple t = test.func1();
        System.out.println("1: " + t.first() + " 2: " + t.second() + " 3: " + t.third());
        test.test1(test.func1());
        test.test1(new TestTuple(0, 0.0, '0'));
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a std::list of boost::shared_ptr<T> and I want to remove an item from
I have code using boost to list directory contents, iterate through each file, and
I have to store a list of different boost::function objects. To provide this I'm
I have a snippet of code like this: std::list<boost::shared_ptr<Point> > left, right; // ...
I have list of articles on the page in table and i want to
I have list of structure. I want to modify a particular data from the
I have List I want to sort Desc by Priority, which is int and
i have list of rows that user select and i want to delete them,
I have list of files which contain particular patterns, but those files have been
I have a list of types defined as: typedef boost::mpl::list<Apple, Pear, Brick> OriginalList; I

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.