|
Boost Users : |
Subject: Re: [Boost-users] [crc] why static data members used in class?
From: John Maddock (jz.maddock_at_[hidden])
Date: 2015-07-09 13:24:45
> I don't understand why the author has used static data members in the
> class below.
> Isn't that an indication that this class cannot be used in a
> multithreaded environment?
>
> class boost::crc_optimal
> {
> public:
> // Type
> typedef implementation_defined value_type;
>
> // Constants reflecting template parameters
> static std::size_t const bit_count = Bits;
> static value_type const truncated_polynominal = TruncPoly;
> static value_type const initial_remainder = InitRem;
> static value_type const final_xor_value = FinalXor;
> static bool const reflect_input = ReflectIn;
> static bool const reflect_remainder = ReflectRem;
static const integer types are all compile-time constants - they're just
fine in a multithreaded environment - and IMO this is the correct way to
define constants that are known at compile time (albeit C++11 adds
constexpr, but it doesn't really change anything in this use case).
HTH, John.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net