none
error C2664: appre::mix_blend' : cannot convert parameter 3 from 'uint32_t' to 'uint32_t &'

    Soru

  • when compile blow code in visual studio 2008, got the C2664 error.

    could anyone help, thanks.


    inline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )
    {
    ...........
    } // 
     
     
    bool appre::cpipe_op(cpipe_line_cont& line ) {
      ................
      for (uint32_t i=0; i< line.size(); i++) {
       // Blend the pixel with a black background => euqal to pre_mult
      line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );
      }

      return true;
    }

    30 Temmuz 2012 Pazartesi 09:04

Yanıtlar

  • when compile blow code in visual studio 2008, got the C2664 error.

    inline pixel appre::mix_blend(

                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )

    bool appre::cpipe_op(cpipe_line_cont& line ) {
      ................
      for (uint32_t i=0; i< line.size(); i++) {
       // Blend the pixel with a black background => euqal to pre_mult
      line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );
      }

    The error message seems clear enough.

    "If a temporary object is passed to a function that takes a
    reference to an object as a parameter, that reference must
    be a const reference."

    The mix_blend function expects a reference for the
    3rd argument. You're casting to a non-reference
    type. An implicit cast/conversion from the type
    you have cast to (uint32_t) to the type required
    by the function is needed, so a temporary variable
    gets created. But you can't pass that temporary
    object to the function unless its 3rd argument
    is declared as const.

    Why are you casting to uint32_t instead of to uint32_t&?

    This would compile:

    nline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , const uint32_t& a_8 // <<==
                         )
                         
    line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );                     

    Or this:
                         
    nline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )

    line[i] = mix_blend( line[i], dummy, (uint32_t&)line[i][AL] );

    - Wayne
    30 Temmuz 2012 Pazartesi 11:16

Tüm Yanıtlar

  • when compile blow code in visual studio 2008, got the C2664 error.

    inline pixel appre::mix_blend(

                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )

    bool appre::cpipe_op(cpipe_line_cont& line ) {
      ................
      for (uint32_t i=0; i< line.size(); i++) {
       // Blend the pixel with a black background => euqal to pre_mult
      line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );
      }

    The error message seems clear enough.

    "If a temporary object is passed to a function that takes a
    reference to an object as a parameter, that reference must
    be a const reference."

    The mix_blend function expects a reference for the
    3rd argument. You're casting to a non-reference
    type. An implicit cast/conversion from the type
    you have cast to (uint32_t) to the type required
    by the function is needed, so a temporary variable
    gets created. But you can't pass that temporary
    object to the function unless its 3rd argument
    is declared as const.

    Why are you casting to uint32_t instead of to uint32_t&?

    This would compile:

    nline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , const uint32_t& a_8 // <<==
                         )
                         
    line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );                     

    Or this:
                         
    nline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )

    line[i] = mix_blend( line[i], dummy, (uint32_t&)line[i][AL] );

    - Wayne
    30 Temmuz 2012 Pazartesi 11:16
  • when compile blow code in visual studio 2008, got the C2664 error.

    Note that if you are coming from an earlier version of VC++
    such as VC++ 6 or 2003, a change was made starting in VC++
    2005 in order to comply with the ISO C++ Standard.

    Temporary Objects Cannot be Bound to Non-Const References
    Visual Studio 2005
    http://msdn.microsoft.com/en-us/library/cfbk5ddc%28v=VS.80%29.aspx

    "In previous releases of Visual C++, non-const references
    could be bound to temporary objects. Now, temporary objects
    can only be bound to const references."

    - Wayne
    30 Temmuz 2012 Pazartesi 11:40
  • when compile blow code in visual studio 2008, got the C2664 error.

    inline pixel appre::mix_blend(

                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )

    bool appre::cpipe_op(cpipe_line_cont& line ) {
      ................
      for (uint32_t i=0; i< line.size(); i++) {
       // Blend the pixel with a black background => euqal to pre_mult
      line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );
      }

    The error message seems clear enough.

    "If a temporary object is passed to a function that takes a
    reference to an object as a parameter, that reference must
    be a const reference."

    The mix_blend function expects a reference for the
    3rd argument. You're casting to a non-reference
    type. An implicit cast/conversion from the type
    you have cast to (uint32_t) to the type required
    by the function is needed, so a temporary variable
    gets created. But you can't pass that temporary
    object to the function unless its 3rd argument
    is declared as const.

    Why are you casting to uint32_t instead of to uint32_t&?

    This would compile:

    nline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , const uint32_t& a_8 // <<==
                         )
                         
    line[i] = mix_blend( line[i], dummy, (uint32_t)line[i][AL] );                     

    Or this:
                         
    nline pixel appre::mix_blend(
                         pixel& c
                         , pixel& p
                         , uint32_t& a_8
                         )

    line[i] = mix_blend( line[i], dummy, (uint32_t&)line[i][AL] );

    - Wayne

    thanks.
    31 Temmuz 2012 Salı 00:54