mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
sprout/random/unique_seed.hpp 更新
at() メンバ関数を constexpr に変更
This commit is contained in:
parent
72d16afcdc
commit
9823888049
6 changed files with 55 additions and 27 deletions
|
@ -130,12 +130,16 @@ namespace sprout {
|
|||
return elems[i];
|
||||
}
|
||||
reference at(size_type i) {
|
||||
rangecheck(i);
|
||||
return elems[i];
|
||||
return i < size()
|
||||
? elems[i]
|
||||
: (throw std::out_of_range("array<>: index out of range"), elems[i])
|
||||
;
|
||||
}
|
||||
const_reference at(size_type i) const {
|
||||
rangecheck(i);
|
||||
return elems[i];
|
||||
SPROUT_CONSTEXPR const_reference at(size_type i) const {
|
||||
return i < size()
|
||||
? elems[i]
|
||||
: (throw std::out_of_range("array<>: index out of range"), elems[i])
|
||||
;
|
||||
}
|
||||
reference front() {
|
||||
return elems[0];
|
||||
|
|
|
@ -98,12 +98,16 @@ namespace sprout {
|
|||
return elem;
|
||||
}
|
||||
reference at(size_type i) {
|
||||
rangecheck(i);
|
||||
return elem;
|
||||
return i < size()
|
||||
? elem
|
||||
: (throw std::out_of_range("pit<>: index out of range"), elem)
|
||||
;
|
||||
}
|
||||
const_reference at(size_type i) const {
|
||||
rangecheck(i);
|
||||
return elem;
|
||||
SPROUT_CONSTEXPR const_reference at(size_type i) const {
|
||||
return i < size()
|
||||
? elem
|
||||
: (throw std::out_of_range("pit<>: index out of range"), elem)
|
||||
;
|
||||
}
|
||||
reference front() {
|
||||
return elem;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef SPROUT_RANDOM_UNIQUE_SEED_HPP
|
||||
#define SPROUT_RANDOM_UNIQUE_SEED_HPP
|
||||
|
||||
#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR
|
||||
# include <cstddef>
|
||||
# include <type_traits>
|
||||
#endif
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/preprocessor/unique_string.hpp>
|
||||
|
@ -8,7 +12,11 @@
|
|||
//
|
||||
// SPROUT_UNIQUE_SEED
|
||||
//
|
||||
#define SPROUT_UNIQUE_SEED (::sprout::hash_value(SPROUT_PP_UNIQUE_STRING))
|
||||
#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR
|
||||
# define SPROUT_UNIQUE_SEED (::std::integral_constant< ::std::size_t, ::sprout::hash_value(SPROUT_PP_UNIQUE_STRING)>::value)
|
||||
#else
|
||||
# define SPROUT_UNIQUE_SEED (::sprout::hash_value(SPROUT_PP_UNIQUE_STRING))
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_RANDOM_UNIQUE_SEED_HPP
|
||||
|
||||
|
|
|
@ -375,12 +375,16 @@ namespace sprout {
|
|||
return elems[i];
|
||||
}
|
||||
reference at(size_type i) {
|
||||
rangecheck(i);
|
||||
return elems[i];
|
||||
return i < size()
|
||||
? elems[i]
|
||||
: (throw std::out_of_range("basic_string<>: index out of range"), elems[i])
|
||||
;
|
||||
}
|
||||
const_reference at(size_type i) const {
|
||||
rangecheck(i);
|
||||
return elems[i];
|
||||
SPROUT_CONSTEXPR const_reference at(size_type i) const {
|
||||
return i < size()
|
||||
? elems[i]
|
||||
: (throw std::out_of_range("basic_string<>: index out of range"), elems[i])
|
||||
;
|
||||
}
|
||||
reference front() {
|
||||
return elems[0];
|
||||
|
|
|
@ -310,12 +310,16 @@ namespace sprout {
|
|||
return *sprout::next(sprout::begin(get_array()), first_ + i);
|
||||
}
|
||||
reference at(size_type i) {
|
||||
rangecheck(i);
|
||||
return *sprout::next(sprout::begin(get_array()), first_ + i);
|
||||
return i < size()
|
||||
? *sprout::next(sprout::begin(get_array()), first_ + i)
|
||||
: (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), first_ + i))
|
||||
;
|
||||
}
|
||||
const_reference at(size_type i) const {
|
||||
rangecheck(i);
|
||||
return *sprout::next(sprout::begin(get_array()), first_ + i);
|
||||
SPROUT_CONSTEXPR const_reference at(size_type i) const {
|
||||
return i < size()
|
||||
? *sprout::next(sprout::begin(get_array()), first_ + i)
|
||||
: (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), first_ + i))
|
||||
;
|
||||
}
|
||||
reference front() {
|
||||
return *sprout::next(sprout::begin(get_array()), first_);
|
||||
|
|
|
@ -157,12 +157,16 @@ namespace sprout {
|
|||
return elems[i];
|
||||
}
|
||||
reference at(size_type i) {
|
||||
rangecheck(i);
|
||||
return elems[i];
|
||||
return i < size()
|
||||
? elems[i]
|
||||
: (throw std::out_of_range("uuid: index out of range"), elems[i])
|
||||
;
|
||||
}
|
||||
const_reference at(size_type i) const {
|
||||
rangecheck(i);
|
||||
return elems[i];
|
||||
SPROUT_CONSTEXPR const_reference at(size_type i) const {
|
||||
return i < size()
|
||||
? elems[i]
|
||||
: (throw std::out_of_range("uuid: index out of range"), elems[i])
|
||||
;
|
||||
}
|
||||
reference front() {
|
||||
return elems[0];
|
||||
|
@ -193,7 +197,7 @@ namespace sprout {
|
|||
}
|
||||
void rangecheck(size_type i) const {
|
||||
if (i >= size()) {
|
||||
throw std::out_of_range("uuid<>: index out of range");
|
||||
throw std::out_of_range("uuid: index out of range");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue