diff --git a/doc/examples.qbk b/doc/examples.qbk index 32729d9..ccab2ae 100644 --- a/doc/examples.qbk +++ b/doc/examples.qbk @@ -36,7 +36,7 @@ determine whether to use `memcpy` to optimise the copy operation template T* copy_imp(const T* first, const T* last, T* out, const boost::__true_type&) { - memcpy(out, first, (last-first)*sizeof(T)); + memmove(out, first, (last-first)*sizeof(T)); return out+(last-first); } diff --git a/doc/html/boost_typetraits/background.html b/doc/html/boost_typetraits/background.html index be3cd5f..40d32b9 100644 --- a/doc/html/boost_typetraits/background.html +++ b/doc/html/boost_typetraits/background.html @@ -56,7 +56,7 @@ method available to them.

- + Type Traits

@@ -84,7 +84,7 @@ given.

- + Implementation

@@ -174,7 +174,7 @@ in the default template.

- + Optimized copy

@@ -247,7 +247,7 @@ otherwise it will call the "slow but safe version".

- + Was it worth it?

@@ -280,7 +280,7 @@

-

Table 1.1. Time taken to copy 1000 elements using `copy<const +

Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times in micro-seconds)

@@ -379,7 +379,7 @@

- + Pair of References

@@ -416,7 +416,7 @@ to hold non-reference types, references, and constant references:

-

Table 1.2. Required Constructor Argument Types

+

Table 1.2. Required Constructor Argument Types

@@ -481,7 +481,7 @@ adds a reference to its type, unless it is already a reference.

-

Table 1.3. Using add_reference to synthesize the correct constructor +

Table 1.3. Using add_reference to synthesize the correct constructor type

@@ -598,7 +598,7 @@ easier to maintain and easier to understand.

- + Conclusion

@@ -611,7 +611,7 @@ can be optimal as well as generic.

- + Acknowledgements

@@ -619,7 +619,7 @@ comments when preparing this article.

- + References
    diff --git a/doc/html/boost_typetraits/category/transform.html b/doc/html/boost_typetraits/category/transform.html index 025ca05..f8f4e81 100644 --- a/doc/html/boost_typetraits/category/transform.html +++ b/doc/html/boost_typetraits/category/transform.html @@ -91,7 +91,7 @@ struct remove_volatile;
    - + Broken Compiler Workarounds:
    diff --git a/doc/html/boost_typetraits/examples/copy.html b/doc/html/boost_typetraits/examples/copy.html index ea69d10..30e8dde 100644 --- a/doc/html/boost_typetraits/examples/copy.html +++ b/doc/html/boost_typetraits/examples/copy.html @@ -56,7 +56,7 @@ template<typename T> T* copy_imp(const T* first, const T* last, T* out, const boost::true_type&) { - memcpy(out, first, (last-first)*sizeof(T)); + memmove(out, first, (last-first)*sizeof(T)); return out+(last-first); } diff --git a/doc/html/boost_typetraits/history.html b/doc/html/boost_typetraits/history.html index 6c491a0..1468725 100644 --- a/doc/html/boost_typetraits/history.html +++ b/doc/html/boost_typetraits/history.html @@ -27,7 +27,7 @@ History
- + Boost 1.42.0
  • diff --git a/doc/html/boost_typetraits/intrinsics.html b/doc/html/boost_typetraits/intrinsics.html index af2f92f..4c5b4a2 100644 --- a/doc/html/boost_typetraits/intrinsics.html +++ b/doc/html/boost_typetraits/intrinsics.html @@ -71,7 +71,7 @@ of the following macros:

    -

    Table 1.4. Macros for Compiler Intrinsics

    +

    Table 1.4. Macros for Compiler Intrinsics

diff --git a/doc/html/boost_typetraits/reference/add_const.html b/doc/html/boost_typetraits/reference/add_const.html index ee843e3..2060fc7 100644 --- a/doc/html/boost_typetraits/reference/add_const.html +++ b/doc/html/boost_typetraits/reference/add_const.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.5. Examples

+

Table 1.5. Examples

diff --git a/doc/html/boost_typetraits/reference/add_cv.html b/doc/html/boost_typetraits/reference/add_cv.html index 288067b..ac1f5a3 100644 --- a/doc/html/boost_typetraits/reference/add_cv.html +++ b/doc/html/boost_typetraits/reference/add_cv.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.6. Examples

+

Table 1.6. Examples

diff --git a/doc/html/boost_typetraits/reference/add_pointer.html b/doc/html/boost_typetraits/reference/add_pointer.html index 30c106f..27b20a0 100644 --- a/doc/html/boost_typetraits/reference/add_pointer.html +++ b/doc/html/boost_typetraits/reference/add_pointer.html @@ -56,7 +56,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.7. Examples

+

Table 1.7. Examples

diff --git a/doc/html/boost_typetraits/reference/add_reference.html b/doc/html/boost_typetraits/reference/add_reference.html index 7bdd876..93415cd 100644 --- a/doc/html/boost_typetraits/reference/add_reference.html +++ b/doc/html/boost_typetraits/reference/add_reference.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.8. Examples

+

Table 1.8. Examples

diff --git a/doc/html/boost_typetraits/reference/add_volatile.html b/doc/html/boost_typetraits/reference/add_volatile.html index dd48cc4..589b79b 100644 --- a/doc/html/boost_typetraits/reference/add_volatile.html +++ b/doc/html/boost_typetraits/reference/add_volatile.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.9. Examples

+

Table 1.9. Examples

diff --git a/doc/html/boost_typetraits/reference/decay.html b/doc/html/boost_typetraits/reference/decay.html index bde3e78..6abe8d6 100644 --- a/doc/html/boost_typetraits/reference/decay.html +++ b/doc/html/boost_typetraits/reference/decay.html @@ -48,7 +48,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.10. Examples

+

Table 1.10. Examples

diff --git a/doc/html/boost_typetraits/reference/floating_point_promotion.html b/doc/html/boost_typetraits/reference/floating_point_promotion.html index 9e12ecd..98b454a 100644 --- a/doc/html/boost_typetraits/reference/floating_point_promotion.html +++ b/doc/html/boost_typetraits/reference/floating_point_promotion.html @@ -49,7 +49,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.11. Examples

+

Table 1.11. Examples

diff --git a/doc/html/boost_typetraits/reference/function_traits.html b/doc/html/boost_typetraits/reference/function_traits.html index a12a921..e22ca2b 100644 --- a/doc/html/boost_typetraits/reference/function_traits.html +++ b/doc/html/boost_typetraits/reference/function_traits.html @@ -59,7 +59,7 @@

-

Table 1.12. Function Traits Members

+

Table 1.12. Function Traits Members

@@ -122,7 +122,7 @@

-

Table 1.13. Examples

+

Table 1.13. Examples

diff --git a/doc/html/boost_typetraits/reference/integral_promotion.html b/doc/html/boost_typetraits/reference/integral_promotion.html index 6ec3c9b..66d27d2 100644 --- a/doc/html/boost_typetraits/reference/integral_promotion.html +++ b/doc/html/boost_typetraits/reference/integral_promotion.html @@ -49,7 +49,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.14. Examples

+

Table 1.14. Examples

diff --git a/doc/html/boost_typetraits/reference/make_signed.html b/doc/html/boost_typetraits/reference/make_signed.html index ffc5ed8..0b0397d 100644 --- a/doc/html/boost_typetraits/reference/make_signed.html +++ b/doc/html/boost_typetraits/reference/make_signed.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.15. Examples

+

Table 1.15. Examples

diff --git a/doc/html/boost_typetraits/reference/make_unsigned.html b/doc/html/boost_typetraits/reference/make_unsigned.html index 0d896d5..eda938b 100644 --- a/doc/html/boost_typetraits/reference/make_unsigned.html +++ b/doc/html/boost_typetraits/reference/make_unsigned.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.16. Examples

+

Table 1.16. Examples

diff --git a/doc/html/boost_typetraits/reference/promote.html b/doc/html/boost_typetraits/reference/promote.html index 823a806..1c9264e 100644 --- a/doc/html/boost_typetraits/reference/promote.html +++ b/doc/html/boost_typetraits/reference/promote.html @@ -51,7 +51,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.17. Examples

+

Table 1.17. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_all_extents.html b/doc/html/boost_typetraits/reference/remove_all_extents.html index 17993e4..7eb1f2c 100644 --- a/doc/html/boost_typetraits/reference/remove_all_extents.html +++ b/doc/html/boost_typetraits/reference/remove_all_extents.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.18. Examples

+

Table 1.18. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_const.html b/doc/html/boost_typetraits/reference/remove_const.html index bebec75..94c714c 100644 --- a/doc/html/boost_typetraits/reference/remove_const.html +++ b/doc/html/boost_typetraits/reference/remove_const.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.19. Examples

+

Table 1.19. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_cv.html b/doc/html/boost_typetraits/reference/remove_cv.html index fe73b51..c46370d 100644 --- a/doc/html/boost_typetraits/reference/remove_cv.html +++ b/doc/html/boost_typetraits/reference/remove_cv.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.20. Examples

+

Table 1.20. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_extent.html b/doc/html/boost_typetraits/reference/remove_extent.html index 35c29c1..a14cef9 100644 --- a/doc/html/boost_typetraits/reference/remove_extent.html +++ b/doc/html/boost_typetraits/reference/remove_extent.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.21. Examples

+

Table 1.21. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_pointer.html b/doc/html/boost_typetraits/reference/remove_pointer.html index 761fe7a..22e6f4f 100644 --- a/doc/html/boost_typetraits/reference/remove_pointer.html +++ b/doc/html/boost_typetraits/reference/remove_pointer.html @@ -55,7 +55,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.22. Examples

+

Table 1.22. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_reference.html b/doc/html/boost_typetraits/reference/remove_reference.html index a5aecf1..275470e 100644 --- a/doc/html/boost_typetraits/reference/remove_reference.html +++ b/doc/html/boost_typetraits/reference/remove_reference.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.23. Examples

+

Table 1.23. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_volatile.html b/doc/html/boost_typetraits/reference/remove_volatile.html index 7a1333b..c007bb4 100644 --- a/doc/html/boost_typetraits/reference/remove_volatile.html +++ b/doc/html/boost_typetraits/reference/remove_volatile.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.24. Examples

+

Table 1.24. Examples

diff --git a/doc/html/index.html b/doc/html/index.html index e60d785..3a49f95 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -30,7 +30,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek

-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

diff --git a/examples/copy_example.cpp b/examples/copy_example.cpp index d90cec0..b6bba2c 100644 --- a/examples/copy_example.cpp +++ b/examples/copy_example.cpp @@ -52,7 +52,7 @@ I2 copy_imp(I1 first, I1 last, I2 out, const boost::integral_constant&) template T* copy_imp(const T* first, const T* last, T* out, const boost::true_type&) { - memcpy(out, first, (last-first)*sizeof(T)); + memmove(out, first, (last-first)*sizeof(T)); return out+(last-first); } @@ -71,7 +71,18 @@ inline I2 copy(I1 first, I1 last, I2 out) return detail::copy_imp(first, last, out, boost::has_trivial_assign()); } -}; // namespace opt +} // namespace opt + +namespace non_opt +{ + +template +inline I2 copy(I1 first, I1 last, I2 out) +{ + return opt::detail::copy_imp(first, last, out, boost::false_type()); +} + +} // // define some global data: @@ -114,6 +125,18 @@ int cpp_main(int argc, char* argv[]) result = t.elapsed(); cout << "opt::copy: " << result << endl; + // cache load: + non_opt::copy(ci_array, ci_array + array_size, i_array); + + // time non-optimised version: + t.restart(); + for(i = 0; i < iter_count; ++i) + { + non_opt::copy(ci_array, ci_array + array_size, i_array); + } + result = t.elapsed(); + cout << "non_opt::copy: " << result << endl; + // cache load: std::copy(ci_array, ci_array + array_size, i_array); @@ -138,6 +161,18 @@ int cpp_main(int argc, char* argv[]) result = t.elapsed(); cout << "opt::copy: " << result << endl; + // cache load: + non_opt::copy(cc_array, cc_array + array_size, c_array); + + // time optimised version: + t.restart(); + for(i = 0; i < iter_count; ++i) + { + non_opt::copy(cc_array, cc_array + array_size, c_array); + } + result = t.elapsed(); + cout << "non_opt::copy: " << result << endl; + // cache load: std::copy(cc_array, cc_array + array_size, c_array); diff --git a/examples/fill_example.cpp b/examples/fill_example.cpp index 67a9bca..3e3af06 100644 --- a/examples/fill_example.cpp +++ b/examples/fill_example.cpp @@ -69,7 +69,17 @@ inline void fill(I first, I last, const T& val) detail::do_fill(first, last, val, truth_type()); } -}; // namespace opt +} // namespace opt + +namespace non_opt{ + +template +inline void fill(I first, I last, const T& val) +{ + opt::detail::do_fill(first, last, val, boost::false_type()); +} + +} // // define some global data: @@ -118,6 +128,18 @@ int cpp_main(int argc, char* argv[]) result = t.elapsed(); cout << "opt::fill: " << result << endl; + // cache load: + non_opt::fill(c_array, c_array + array_size, (char)3); + + // time optimised version: + t.restart(); + for(i = 0; i < iter_count; ++i) + { + non_opt::fill(c_array, c_array + array_size, (char)3); + } + result = t.elapsed(); + cout << "non_opt::fill: " << result << endl; + // cache load: std::fill(c_array, c_array + array_size, (char)3); @@ -144,6 +166,18 @@ int cpp_main(int argc, char* argv[]) result = t.elapsed(); cout << "opt::fill: " << result << endl; + // cache load: + non_opt::fill(i_array, i_array + array_size, 3); + + // timer optimised version: + t.restart(); + for(i = 0; i < iter_count; ++i) + { + non_opt::fill(i_array, i_array + array_size, 3); + } + result = t.elapsed(); + cout << "non_opt::fill: " << result << endl; + // cache load: std::fill(i_array, i_array + array_size, 3); diff --git a/test/aligned_storage_empy_test.cpp b/test/aligned_storage_empy_test.cpp index 28e9e20..23e62bf 100644 --- a/test/aligned_storage_empy_test.cpp +++ b/test/aligned_storage_empy_test.cpp @@ -53,7 +53,7 @@ namespace } template< class T > - void check() + void do_check() { std::ptrdiff_t addr1 = get_address1<0,T>(); std::ptrdiff_t addr2 = get_address2<0,T>(); @@ -90,31 +90,31 @@ namespace TT_TEST_BEGIN(type_with_empty_alignment_buffer) -check(); -check(); -check(); -check(); -check(); -check(); -check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); #ifdef BOOST_HAS_MS_INT64 -check<__int64>(); +do_check<__int64>(); #endif #ifdef BOOST_HAS_LONG_LONG -check(); +do_check(); #endif -check(); -check(); -check(); -check(); -check(); -check(); -check(); -check(); -check(); -check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); +do_check(); TT_TEST_END diff --git a/test/aligned_storage_test.cpp b/test/aligned_storage_test.cpp index 9f531ee..372bac3 100644 --- a/test/aligned_storage_test.cpp +++ b/test/aligned_storage_test.cpp @@ -28,7 +28,7 @@ inline void no_unused_warning(const volatile T&) } template -void check(const T&) +void do_check(const T&) { typedef typename tt::aligned_storage::type t1; t1 as1 = { 0, }; @@ -74,31 +74,31 @@ void check(const T&) TT_TEST_BEGIN(type_with_alignment) -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); #ifdef BOOST_HAS_LONG_LONG -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); #endif #ifdef BOOST_HAS_MS_INT64 -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); #endif -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); TT_TEST_END diff --git a/test/aligned_storage_test_a2.cpp b/test/aligned_storage_test_a2.cpp index 47fe3c4..73a9e4c 100644 --- a/test/aligned_storage_test_a2.cpp +++ b/test/aligned_storage_test_a2.cpp @@ -32,7 +32,7 @@ inline void no_unused_warning(const volatile T&) } template -void check(const T&) +void do_check(const T&) { typedef typename tt::aligned_storage::type t1; t1 as1 = { 0, }; @@ -75,31 +75,31 @@ void check(const T&) TT_TEST_BEGIN(type_with_alignment) -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); #ifdef BOOST_HAS_LONG_LONG -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); #endif #ifdef BOOST_HAS_MS_INT64 -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); #endif -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); -check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); +do_check(tt::integral_constant::value>()); TT_TEST_END