C++ 64 bit int: pass by reference or pass by value

后端 未结 5 1136
悲哀的现实
悲哀的现实 2020-12-31 05:46

This is an efficiency question about 64 bit ints. Assuming I don\'t need to modify the value of a \"int\" parameter, should I pass it by value or reference.

Assu

5条回答
  •  一向
    一向 (楼主)
    2020-12-31 06:01

    Pass them as a boost::call_traits::param_type. This template captures the best practices for passing any type on the supported platforms. Hence, it will be different on 32 and 64 bits platforms, but you can use the same code everywhere. It even works inside other templates where you don't know the precise type yet.

提交回复
热议问题