Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76909 - in sandbox/SOC/2011/checks: boost/checks libs/checks/test
From: pierre.talbot.6114_at_[hidden]
Date: 2012-02-06 10:42:48


Author: trademark
Date: 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
New Revision: 76909
URL: http://svn.boost.org/trac/boost/changeset/76909

Log:
Remove int / unsigned int and use std::size_t, Remove default checkdigit_size. Change weight::weight_associated_with_pos by weight::at
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/amex.hpp | 8 +++++---
   sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp | 14 +++++++-------
   sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp | 28 +++++++++++++++-------------
   sandbox/SOC/2011/checks/boost/checks/isbn.hpp | 6 +++---
   sandbox/SOC/2011/checks/boost/checks/limits.hpp | 21 +++++++++++----------
   sandbox/SOC/2011/checks/boost/checks/luhn.hpp | 8 ++++----
   sandbox/SOC/2011/checks/boost/checks/mastercard.hpp | 6 +++---
   sandbox/SOC/2011/checks/boost/checks/modulus10.hpp | 7 ++++---
   sandbox/SOC/2011/checks/boost/checks/modulus11.hpp | 12 ++++++------
   sandbox/SOC/2011/checks/boost/checks/modulus97.hpp | 12 ++++++------
   sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp | 16 +++++++++-------
   sandbox/SOC/2011/checks/boost/checks/visa.hpp | 6 +++---
   sandbox/SOC/2011/checks/boost/checks/weight.hpp | 15 ++++++++-------
   sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp | 6 +++---
   sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp | 6 +++---
   15 files changed, 90 insertions(+), 81 deletions(-)

Modified: sandbox/SOC/2011/checks/boost/checks/amex.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/amex.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/amex.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -16,6 +16,8 @@
     #pragma once
 #endif
 
+#include <cstddef> // std::size_t
+
 #include <boost/checks/luhn.hpp>
 
 #include <boost/range/rbegin.hpp>
@@ -39,7 +41,7 @@
 
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct amex_algorithm : boost::checks::luhn_algorithm <checkdigit_size>
 {
   /*!
@@ -52,9 +54,9 @@
 
     \remarks This function use the macro AMEX_SIZE to find the real position from left to right.
   */
- static void filter_valid_value_with_pos(unsigned int current_valid_value, unsigned int current_value_position)
+ static void filter_valid_value_with_pos(std::size_t current_valid_value, std::size_t current_value_position)
   {
- const unsigned int real_pos_from_left = AMEX_SIZE - current_value_position - checkdigit_size;
+ std::size_t real_pos_from_left = AMEX_SIZE - current_value_position - checkdigit_size;
 
     if(real_pos_from_left == 1 && current_valid_value != 3)
       throw std::invalid_argument("The Major Industry Identifier of an American Express should be 3!");

Modified: sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -31,7 +31,7 @@
     \tparam traversal_direction must meet the iterator_direction concept requirements.
     \tparam checkdigit_size Helper functions to provide the same behavior on sequence with and without checkdigits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct basic_check_algorithm
 {
   /*!
@@ -46,7 +46,7 @@
     \returns the translation of the current value in the range [0..9].
 */
   template <typename value_type>
- static int translate_to_valid_value(const value_type &value)
+ static std::size_t translate_to_valid_value(const value_type &value)
   {
     if(value > 9)
       throw boost::checks::translation_exception();
@@ -62,7 +62,7 @@
 
     \remarks This function should be overloaded if you want to check a sequence.
   */
- static bool validate_checksum(int checksum)
+ static bool validate_checksum(std::size_t checksum)
   {
     return true;
   }
@@ -80,7 +80,7 @@
     \remarks This function should be overloaded if you want to compute the check digit of a sequence.
   */
   template <typename checkdigit>
- static checkdigit compute_checkdigit(int checksum)
+ static checkdigit compute_checkdigit(std::size_t checksum)
   {
     return checkdigit();
   }
@@ -99,7 +99,7 @@
     \remarks This function should be overloaded if you want your algorithm to compute more than one check digit (through it works for just one check digit too).
   */
   template <typename checkdigits_iter>
- static checkdigits_iter compute_multicheckdigit(int checksum, checkdigits_iter checkdigits)
+ static checkdigits_iter compute_multicheckdigit(std::size_t checksum, checkdigits_iter checkdigits)
   {
     return checkdigits;
   }
@@ -114,7 +114,7 @@
 
     \remarks This function should be overloaded if you want to calculate the checksum of a sequence.
   */
- static void operate_on_valid_value(int current_valid_value, unsigned int valid_value_counter, int &checksum)
+ static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
   {
   }
 
@@ -128,7 +128,7 @@
 
     \remarks This function should be overloaded if you want to filter the values with their positions.
   */
- static void filter_valid_value_with_pos(unsigned int current_valid_value, unsigned int current_value_position)
+ static void filter_valid_value_with_pos(std::size_t current_valid_value, std::size_t current_value_position)
   {
   }
 };

Modified: sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -16,6 +16,8 @@
     #pragma once
 #endif
 
+#include <cstddef> // std::size_t
+
 #include <boost/checks/translation_exception.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/checks/limits.hpp>
@@ -27,15 +29,15 @@
 namespace detail
 {
   template <typename value_type>
- int lexical_cast(value_type x)
+ std::size_t lexical_cast(value_type x)
   {
     // If it's a character, transform digit to int (for example: '1' to 1).
     try
     {
- return boost::lexical_cast<int>(x);
+ return boost::lexical_cast<std::size_t>(x);
     }
     catch(boost::bad_lexical_cast){}
- return static_cast<int>(x);
+ return static_cast<std::size_t>(x);
   }
 }
 
@@ -55,15 +57,15 @@
     \returns The checksum of the sequence calculated with algorithm.
   */
 template <typename algorithm, typename size_contract, typename seq_iterator>
-int compute_checksum(seq_iterator seq_begin, seq_iterator seq_end)
+std::size_t compute_checksum(seq_iterator seq_begin, seq_iterator seq_end)
 {
- unsigned int value_counter = 0;
- int checksum = 0;
+ std::size_t value_counter = 0;
+ std::size_t checksum = 0;
   for(; seq_begin != seq_end && !size_contract::reach_one_past_the_end(value_counter); ++seq_begin)
   {
     try
     {
- int value = boost::checks::detail::lexical_cast(*seq_begin);
+ std::size_t value = boost::checks::detail::lexical_cast(*seq_begin);
       value = algorithm::translate_to_valid_value(value);
       algorithm::filter_valid_value_with_pos(value, value_counter);
       algorithm::operate_on_valid_value(value, value_counter, checksum);
@@ -92,7 +94,7 @@
 template <typename algorithm, typename seq_iterator>
 bool check_sequence(seq_iterator seq_begin, seq_iterator seq_end)
 {
- int checksum = compute_checksum<algorithm, boost::checks::no_null_size_contract<> >(seq_begin, seq_end);
+ std::size_t checksum = compute_checksum<algorithm, boost::checks::no_null_size_contract<> >(seq_begin, seq_end);
   return algorithm::validate_checksum(checksum);
 }
 
@@ -113,7 +115,7 @@
 template <typename algorithm, size_t size_expected, typename seq_iterator>
 bool check_sequence(seq_iterator seq_begin, seq_iterator seq_end)
 {
- int checksum = compute_checksum<algorithm, boost::checks::strict_size_contract<size_expected> >(seq_begin, seq_end);
+ std::size_t checksum = compute_checksum<algorithm, boost::checks::strict_size_contract<size_expected> >(seq_begin, seq_end);
   return algorithm::validate_checksum(checksum);
 }
 
@@ -133,7 +135,7 @@
 template <typename algorithm, typename seq_iterator>
 typename seq_iterator::value_type compute_checkdigit(seq_iterator seq_begin, seq_iterator seq_end)
 {
- int checksum = compute_checksum<algorithm, boost::checks::no_null_size_contract<> >(seq_begin, seq_end);
+ std::size_t checksum = compute_checksum<algorithm, boost::checks::no_null_size_contract<> >(seq_begin, seq_end);
   return algorithm::template compute_checkdigit<typename seq_iterator::value_type>(checksum);
 }
 
@@ -154,7 +156,7 @@
 template <typename algorithm, size_t size_expected, typename seq_iterator>
 typename seq_iterator::value_type compute_checkdigit(seq_iterator seq_begin, seq_iterator seq_end)
 {
- int checksum = compute_checksum<algorithm, boost::checks::strict_size_contract<size_expected> >(seq_begin, seq_end);
+ std::size_t checksum = compute_checksum<algorithm, boost::checks::strict_size_contract<size_expected> >(seq_begin, seq_end);
   return algorithm::template compute_checkdigit<typename seq_iterator::value_type>(checksum);
 }
 
@@ -177,7 +179,7 @@
 template <typename algorithm, typename seq_iterator, typename checkdigit_iterator>
 checkdigit_iterator compute_multicheckdigit (seq_iterator seq_begin, seq_iterator seq_end, checkdigit_iterator checkdigits)
 {
- int checksum = compute_checksum<algorithm, boost::checks::no_null_size_contract<> >(seq_begin, seq_end);
+ std::size_t checksum = compute_checksum<algorithm, boost::checks::no_null_size_contract<> >(seq_begin, seq_end);
   return algorithm::compute_multicheckdigit(checksum, checkdigits);
 }
 
@@ -200,7 +202,7 @@
 template <typename algorithm, size_t size_expected, typename seq_iterator, typename checkdigit_iterator>
 checkdigit_iterator compute_multicheckdigit (seq_iterator seq_begin, seq_iterator seq_end, checkdigit_iterator checkdigits)
 {
- int checksum = compute_checksum<algorithm, boost::checks::strict_size_contract<size_expected> >(seq_begin, seq_end);
+ std::size_t checksum = compute_checksum<algorithm, boost::checks::strict_size_contract<size_expected> >(seq_begin, seq_end);
   return algorithm::compute_multicheckdigit(checksum, checkdigits);
 }
 

Modified: sandbox/SOC/2011/checks/boost/checks/isbn.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/isbn.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/isbn.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -42,7 +42,7 @@
 
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct isbn13_algorithm : boost::checks::modulus10_algorithm<boost::checks::ean_weight, checkdigit_size>
 {
   /*!
@@ -55,9 +55,9 @@
 
     \remarks This function use the macro EAN13_SIZE to find the real position from left to right.
   */
- static void filter_valid_value_with_pos(unsigned int value, unsigned int value_position)
+ static void filter_valid_value_with_pos(std::size_t value, std::size_t value_position)
   {
- unsigned int real_pos_from_left = EAN13_SIZE - value_position - checkdigit_size;
+ std::size_t real_pos_from_left = EAN13_SIZE - value_position - checkdigit_size;
 
     if(real_pos_from_left == 1 && value != 9)
       throw std::invalid_argument("The first digit should be 9!");

Modified: sandbox/SOC/2011/checks/boost/checks/limits.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/limits.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/limits.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -16,6 +16,7 @@
     #pragma once
 #endif
 
+#include <cstddef>
 #include <boost/static_assert.hpp>
 
 namespace boost{
@@ -27,32 +28,32 @@
     \tparam expected_size The expected size of the sequence. (Expected_size > 0, enforced with static assert).
     \tparam exception_size_failure If the size is not respected an exception_size_failure exception will be thrown. Default exception class is std::invalid_argument.
 */
-template <size_t expected_size, class exception_size_failure = std::invalid_argument>
+template <std::size_t expected_size, class exception_size_failure = std::invalid_argument>
 struct strict_size_contract
 {
- /*! \fn static void respect_size_contract(const size_t valid_value_counter)
+ /*! \fn static void respect_size_contract(const std::size_t valid_value_counter)
     \brief Enforce the size contract.
 
     \param valid_value_counter Number of valid values in the sequence.
     \throws exception_size_failure If the terms of the contract are not respected. (valid_value_counter != expected_size).
   */
- static void respect_size_contract(size_t valid_value_counter)
+ static void respect_size_contract(std::size_t valid_value_counter)
   {
     BOOST_STATIC_ASSERT_MSG( expected_size > 0 , "The expected size must be greater than 0!" );
     if( valid_value_counter != expected_size )
       throw exception_size_failure("Too few or too many valid values in the sequence!") ;
   }
 
- /*! \fn static bool reach_one_past_the_end(const size_t valid_value_counter)
+ /*! \fn static bool reach_one_past_the_end(const std::size_t valid_value_counter)
     \brief Tells if the expected interval of value [0..n) is outstripped.
 
     \param valid_value_counter Number of valid values in the sequence already counted.
     \returns true if valid_value_counter is one past the end of the expected size, else false.
   */
- static bool reach_one_past_the_end(size_t valid_value_counter)
+ static bool reach_one_past_the_end(std::size_t valid_value_counter)
   {
     BOOST_STATIC_ASSERT_MSG( expected_size > 0 , "The expected size must be greater than 0!" );
- return valid_value_counter > expected_size ;
+ return valid_value_counter > expected_size;
   }
 };
 
@@ -64,25 +65,25 @@
 template <class exception_size_failure = std::invalid_argument>
 struct no_null_size_contract
 {
-/*! \fn static void respect_size_contract(const size_t valid_value_counter)
+/*! \fn static void respect_size_contract(const std::size_t valid_value_counter)
     \brief Enforce the size contract.
 
     \param valid_value_counter Number of valid values in the sequence.
     \throws exception_size_failure if the terms of the contract are not respected. (valid_value_counter == 0).
   */
- static void respect_size_contract(size_t valid_value_counter)
+ static void respect_size_contract(std::size_t valid_value_counter)
   {
     if( valid_value_counter == 0 )
       throw exception_size_failure("No valid value in this sequence!") ;
   }
 
-/*! \fn static bool reach_one_past_the_end(const size_t valid_value_counter)
+/*! \fn static bool reach_one_past_the_end(const std::size_t valid_value_counter)
     \brief Warns if the expected interval of value [0..n) is exceeded.
 
     \param valid_value_counter Number of valid values in the sequence already counted.
     \returns false.
   */
- static bool reach_one_past_the_end(size_t /* valid_value_counter */)
+ static bool reach_one_past_the_end(std::size_t /* valid_value_counter */)
   {
     return false;
   }

Modified: sandbox/SOC/2011/checks/boost/checks/luhn.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/luhn.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/luhn.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -35,7 +35,7 @@
 
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct luhn_algorithm : boost::checks::modulus10_algorithm <luhn_weight, checkdigit_size>
 {
   /*!
@@ -49,10 +49,10 @@
 
     \remarks This function become obsolete if you don't use luhn_weight. It is using operator "<<" to make internal multiplication.
   */
- static void operate_on_valid_value(const int current_valid_value, const unsigned int valid_value_counter, int &checksum)
+ static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
   {
- int current_weight = luhn_weight::weight_associated_with_pos(valid_value_counter + checkdigit_size);
- int weighted_value = current_valid_value << (current_weight-1);
+ std::size_t current_weight = luhn_weight::at(valid_value_counter + checkdigit_size);
+ std::size_t weighted_value = current_valid_value << (current_weight-1);
     checksum += weighted_value % 10 + weighted_value / 10;
   }
 };

Modified: sandbox/SOC/2011/checks/boost/checks/mastercard.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/mastercard.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/mastercard.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -39,7 +39,7 @@
 
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct mastercard_algorithm : boost::checks::luhn_algorithm <checkdigit_size>
 {
   /*!
@@ -52,9 +52,9 @@
 
     \remarks This function use the macro MASTERCARD_SIZE to find the real position from left to right.
   */
- static void filter_valid_value_with_pos(const unsigned int current_valid_value, const unsigned int current_value_position)
+ static void filter_valid_value_with_pos(std::size_t current_valid_value, std::size_t current_value_position)
   {
- const unsigned int real_pos_from_left = MASTERCARD_SIZE - current_value_position - checkdigit_size;
+ std::size_t real_pos_from_left = MASTERCARD_SIZE - current_value_position - checkdigit_size;
 
     if(real_pos_from_left == 1 && current_valid_value != 5)
       throw std::invalid_argument("The Major Industry Identifier of a Mastercard should be 5!");

Modified: sandbox/SOC/2011/checks/boost/checks/modulus10.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus10.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus10.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -16,6 +16,7 @@
     #pragma once
 #endif
 
+#include <cstddef>
 #include <boost/lexical_cast.hpp>
 #include <boost/checks/weighted_sum.hpp>
 
@@ -29,7 +30,7 @@
     \tparam iteration_sense must meet the iteration_sense concept requirements.
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <typename mod10_weight, std::size_t checkdigit_size = 0>
+template <typename mod10_weight, std::size_t checkdigit_size>
 struct modulus10_algorithm : boost::checks::weighted_sum_algorithm<mod10_weight, checkdigit_size>
 {
   /*!
@@ -39,7 +40,7 @@
 
     \returns @c true if the checksum is correct, @c false otherwise.
   */
- static bool validate_checksum(int checksum)
+ static bool validate_checksum(std::size_t checksum)
   {
     return !(checksum % 10);
   }
@@ -55,7 +56,7 @@
     \returns The modulus 10 check digit of checksum.
   */
   template <typename checkdigit>
- static checkdigit compute_checkdigit(int checksum)
+ static checkdigit compute_checkdigit(std::size_t checksum)
   {
     return boost::lexical_cast<checkdigit>((10 - checksum % 10) % 10);
   }

Modified: sandbox/SOC/2011/checks/boost/checks/modulus11.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus11.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus11.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -37,7 +37,7 @@
 
     \remarks The range of the check digit is [0..10], the tenth element is translated as the letter 'X'.
 */
-template <typename mod11_weight, std::size_t checkdigit_size = 0>
+template <typename mod11_weight, std::size_t checkdigit_size>
 struct modulus11_algorithm : boost::checks::weighted_sum_algorithm<mod11_weight, checkdigit_size>
 {
 
@@ -53,7 +53,7 @@
     \returns the translation of the current value in the range [0..10].
 */
   template <typename value_type>
- static int translate_to_valid_value(const value_type &value)
+ static std::size_t translate_to_valid_value(const value_type &value)
   {
     int valid_value = value;
     if(value == 'x' || value == 'X')
@@ -64,7 +64,7 @@
   }
 
 /* pre: value must be valid */
- static void filter_valid_value_with_pos(unsigned int value, unsigned int value_position)
+ static void filter_valid_value_with_pos(std::size_t value, std::size_t value_position)
   {
     // Must be the first digit if the value == 'X'. (reverse traversal).
     if(value == 'X' || value == 'x')
@@ -84,7 +84,7 @@
 
     \returns true if the checksum is correct, false otherwise.
   */
- static bool validate_checksum(int checksum)
+ static bool validate_checksum(std::size_t checksum)
   {
     return !(checksum % 11);
   }
@@ -100,14 +100,14 @@
     \returns The modulus 11 check digit of checksum. 'X' is returned if the check digit value is equal to 10.
   */
   template <typename checkdigit>
- static checkdigit compute_checkdigit(int checksum)
+ static checkdigit compute_checkdigit(std::size_t checksum)
   {
      return translate_checkdigit<checkdigit>((11 - checksum % 11)% 11);
   }
 
 protected:
   template <typename checkdigit>
- static checkdigit translate_checkdigit(int _checkdigit)
+ static checkdigit translate_checkdigit(std::size_t _checkdigit)
   {
     if(_checkdigit == 10)
       return static_cast<checkdigit>('X');

Modified: sandbox/SOC/2011/checks/boost/checks/modulus97.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus97.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus97.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -37,7 +37,7 @@
 
     \remarks This algorithm use two check digits.
 */
-template <typename mod97_weight, std::size_t checkdigit_size = 0>
+template <typename mod97_weight, std::size_t checkdigit_size>
 struct modulus97_algorithm : boost::checks::weighted_sum_algorithm<mod97_weight, checkdigit_size>
 {
   /*!
@@ -47,7 +47,7 @@
 
     \returns @c true if the checksum is correct, @c false otherwise.
   */
- static bool validate_checksum(int checksum)
+ static bool validate_checksum(std::size_t checksum)
   {
     return checksum % 97 == 1;
   }
@@ -67,9 +67,9 @@
     \returns An iterator initialized at one pass to the end of the two check digits.
   */
   template <typename checkdigits_iter>
- static checkdigits_iter compute_multicheckdigit(int checksum, checkdigits_iter checkdigits)
+ static checkdigits_iter compute_multicheckdigit(std::size_t checksum, checkdigits_iter checkdigits)
   {
- unsigned int mod97_checkdigits = 98 - (checksum % 97);
+ std::size_t mod97_checkdigits = 98 - (checksum % 97);
 
     try
     {
@@ -92,10 +92,10 @@
 
     \remarks The last value is 68, so we specialize make_mod97_weight to terminate the template recursion.
 */
-template <unsigned int weight_value>
+template <std::size_t weight_value>
 struct make_mod97_weight
 {
- static const unsigned int value = weight_value;
+ static const std::size_t value = weight_value;
   typedef make_mod97_weight<weight_value * 10 % 97> next;
 };
 /*! \class make_mod97_weight

Modified: sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -17,6 +17,8 @@
     #pragma once
 #endif
 
+#include <cstddef>
+
 #include <boost/range/rbegin.hpp>
 #include <boost/range/rend.hpp>
 #include <boost/range/iterator_range.hpp>
@@ -34,7 +36,7 @@
 
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct verhoeff_algorithm : boost::checks::basic_check_algorithm<checkdigit_size>
 {
   /*!
@@ -48,9 +50,9 @@
 
     \remarks This function use the classic table d and p of the Verhoeff algorithm.
   */
- static void operate_on_valid_value(const int current_valid_value, const unsigned int valid_value_counter, int &checksum)
+ static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
   {
- static const unsigned int d[10][10] =
+ static const unsigned char d[10][10] =
     {
       { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
       { 1, 2, 3, 4, 0, 6, 7, 8, 9, 5 },
@@ -64,7 +66,7 @@
       { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }
     };
 
- static const unsigned int p[8][10] =
+ static const unsigned char p[8][10] =
     {
       { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
       { 1, 5, 7, 6, 2, 8, 3, 0, 9, 4 },
@@ -86,7 +88,7 @@
 
     \returns @c true if the checksum is correct, @c false otherwise.
   */
- static bool validate_checksum(int checksum)
+ static bool validate_checksum(std::size_t checksum)
   {
     return !checksum;
   }
@@ -102,9 +104,9 @@
     \returns The Verhoeff check digit of checksum.
   */
   template <typename checkdigit>
- static checkdigit compute_checkdigit(int checksum)
+ static checkdigit compute_checkdigit(std::size_t checksum)
   {
- static const unsigned int inv[] = {0, 4, 3, 2, 1, 5, 6, 7, 8, 9};
+ static const unsigned char inv[] = {0, 4, 3, 2, 1, 5, 6, 7, 8, 9};
 
     try
     {

Modified: sandbox/SOC/2011/checks/boost/checks/visa.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/visa.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/visa.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -39,7 +39,7 @@
 
     \tparam checkdigit_size Helper functions to provide same behavior on a sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <std::size_t checkdigit_size = 0>
+template <std::size_t checkdigit_size>
 struct visa_algorithm : boost::checks::luhn_algorithm <checkdigit_size>
 {
   /*!
@@ -52,9 +52,9 @@
 
     \remarks This function use the macro VISA_SIZE to find the real position from left to right.
   */
- static void filter_valid_value_with_pos(unsigned int current_valid_value, unsigned int current_value_position)
+ static void filter_valid_value_with_pos(std::size_t current_valid_value, std::size_t current_value_position)
   {
- const unsigned int real_pos_from_left = VISA_SIZE - current_value_position - checkdigit_size;
+ std::size_t real_pos_from_left = VISA_SIZE - current_value_position - checkdigit_size;
 
     if(real_pos_from_left == 1 && current_valid_value != 4)
       throw std::invalid_argument("The Major Industry Identifier of a VISA credit card should be 4!");

Modified: sandbox/SOC/2011/checks/boost/checks/weight.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/weight.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/weight.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -18,6 +18,7 @@
 
 #include <boost/preprocessor/repetition.hpp>
 #include <boost/preprocessor/facilities/intercept.hpp>
+#include <cstddef> // std::size_t
 
 /*! \def BOOST_CHECK_LIMIT_WEIGHTS
     \brief The BOOST_CHECK_LIMIT_WEIGHTS macro defines the maximum number of weights accepted by the library.
@@ -36,28 +37,28 @@
 
     \remarks There are BOOST_CHECK_LIMIT_WEIGHTS partial specialisations of this class.
 */
-template <BOOST_PP_ENUM_BINARY_PARAMS(BOOST_CHECK_LIMIT_WEIGHTS, int weight_value, = 0 BOOST_PP_INTERCEPT) >
+template <BOOST_PP_ENUM_BINARY_PARAMS(BOOST_CHECK_LIMIT_WEIGHTS, std::size_t weight_value, = 0 BOOST_PP_INTERCEPT) >
 struct weight
 {
-/*! \fn static int weight_associated_with_pos(const unsigned int value_pos)
+/*! \fn static int at(std::size_t value_pos)
     \brief Get the weight at the current value position.
 
     \param value_pos is the position of the current value. (0 <= value_pos < n).
     \returns The weight value at the position value_pos.
   */
- static int weight_associated_with_pos(const unsigned int value_pos) { return 1; }
+ static int at(std::size_t value_pos) { return 1; }
 };
 
 #define _WEIGHT_factory(z, weight_size ,unused) \
- template<BOOST_PP_ENUM_PARAMS(weight_size , int weight_value)> \
+ template<BOOST_PP_ENUM_PARAMS(weight_size , std::size_t weight_value)> \
   struct weight<BOOST_PP_ENUM_PARAMS(weight_size, weight_value)> \
   { \
- static int weight_associated_with_pos(const unsigned int value_pos) \
+ static std::size_t at(std::size_t value_pos) \
     { \
- static const int weights[weight_size] = { BOOST_PP_ENUM_PARAMS(weight_size, weight_value) } ; \
+ static const std::size_t weights[weight_size] = { BOOST_PP_ENUM_PARAMS(weight_size, weight_value) } ; \
       return weights[value_pos % weight_size] ; \
     } \
- } ;
+ };
 
 // Develop the macro _WEIGHT_factory BOOST_CHECK_LIMIT_WEIGHTS times.
 BOOST_PP_REPEAT_FROM_TO(1,BOOST_CHECK_LIMIT_WEIGHTS,_WEIGHT_factory,~)

Modified: sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -30,7 +30,7 @@
     \tparam iteration_sense must meet the iteration_sense concept requirements.
     \tparam checkdigit_size Helper function to provide same behavior on sequence with and without checkdigits. No "real" value in the sequence will be skipped.
 */
-template <typename weight, std::size_t checkdigit_size = 0>
+template <typename weight, std::size_t checkdigit_size>
 struct weighted_sum_algorithm : boost::checks::basic_check_algorithm<checkdigit_size>
 {
   /*!
@@ -42,9 +42,9 @@
     \param valid_value_counter is the number of valid values already counted (the current value is not included).\n This is also the position (above the valid values) of the current value analysed (0 <= valid_value_counter < n).
     \param checksum is the current checksum.
   */
- static void operate_on_valid_value(const int current_valid_value, const unsigned int valid_value_counter, int &checksum)
+ static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
   {
- int current_weight = weight::weight_associated_with_pos(valid_value_counter + checkdigit_size);
+ int current_weight = weight::at(valid_value_counter + checkdigit_size);
     checksum += current_valid_value * current_weight;
   }
 };

Modified: sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp (original)
+++ sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp 2012-02-06 10:42:46 EST (Mon, 06 Feb 2012)
@@ -26,15 +26,15 @@
 {
   typedef boost::checks::weight<0,1,2,3,4,5,6,7,8,9> number_suite ;
   for(int i=0 ; i < 100 ; ++i)
- BOOST_CHECK ( i%10 == number_suite::weight_associated_with_pos( i ) ) ;
+ BOOST_CHECK ( i%10 == number_suite::at( i ) ) ;
 
   typedef boost::checks::weight<1,1,1,1,1,1> suite_of_1 ;
   for(int i=0 ; i < 100; ++i)
- BOOST_CHECK ( 1 == suite_of_1::weight_associated_with_pos( i ) ) ;
+ BOOST_CHECK ( 1 == suite_of_1::at( i ) ) ;
 
   typedef boost::checks::weight<> no_weight_specify ;
   for(int i=0 ; i < 100; ++i)
- BOOST_CHECK ( 0 == no_weight_specify::weight_associated_with_pos( i ) ) ;
+ BOOST_CHECK ( 0 == no_weight_specify::at( i ) ) ;
 }
 
 BOOST_AUTO_TEST_CASE(limits_test)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk