Results 1 to 2 of 2

Thread: Problem with boost::array

  1. #1
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem with boost::array

    And probably with templates in general - I've never used them outside of Qt's

    I am trying to pass boost::array< float, int > as a function argument, but GCC is comlaining :

    /home/lawrence/Projects/modelloader/src/modelloader.h:21: error: expected a constant of type ‘int’, got ‘unsigned int’
    /home/lawrence/Projects/modelloader/src/modelloader.h:22: error: type/value mismatch at argument 2 in template parameter list for ‘template<class T, unsigned int N> class boost::array’
    Also, in the implementation .cpp file when I try an create a boost::array it complains :

    /home/lawrence/Projects/modelloader/src/objloader.cc:81: error: ‘num_vertices’ cannot appear in a constant-expression
    /home/lawrence/Projects/modelloader/src/objloader.cc:81: error: template argument 2 is invalid
    Also, I tried earlier to pass it as a pointer :

    boost::array< float, int > *x
    Is that valid syntax?

    TIA.
    Last edited by Valheru; 16th August 2007 at 20:07.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with boost::array

    Quote Originally Posted by Valheru View Post
    Is that valid syntax?
    No, boost::array is meant as a replacement for C-style arrays and it has a constant size that must be known at compile time:
    Qt Code:
    1. boost::array< float, 100 > *x;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  2. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.