Ejemplo n.º 1
0
 T const& get_random(RNG& rng)const {
   caller_error_if(members_to_indices_.empty(), "Trying to get a random element of an empty literally_random_access_set");
   const boost::random::uniform_int_distribution<size_type> random_item_idx(0, pointers_vector_.size()-1);
   const size_type idx = random_item_idx(rng);
   assert(idx < pointers_vector_.size());
   return pointers_vector_[idx]->first;
 }
Ejemplo n.º 2
0
pow2_radix_patricia_trie_node<Dims, Coord, T, Traits>&
pow2_radix_patricia_trie_node<Dims, Coord, T, Traits>::insert(loc_type leaf_loc, T&& new_leaf, monoid_type leaf_monoid) {
  node_type& inserted = this->insert(leaf_loc);
  caller_error_if(inserted.points_to_leaf() && inserted.min() == leaf_loc, "Inserting a leaf in a location that's already in the tree");
  inserted.set_leaf(::move(new_leaf));
  inserted.initialize_monoid_(::move(leaf_monoid));
  return inserted;
}
Ejemplo n.º 3
0
 explicit small_string(const char* s) {
   size_t i = 0;
   for(; s[i] != '\0'; ++i) {
     caller_error_if(i >= info::max_length, "string too large for small_string");
     buf_[i] = s[i];
   }
   for(; i < info::data_len; ++i) {
     buf_[i] = '\0';
   }
 }
Ejemplo n.º 4
0
 bounds_checked_int& operator--() {
     caller_error_if(val_ == Min, "bounds_checked_int underflow");
     --val_;
     return *this;
 }
Ejemplo n.º 5
0
 //as an optimization, use a special check rather than the constructor which calls check_valid_.
 bounds_checked_int& operator++() {
     caller_error_if(val_ == Max, "bounds_checked_int overflow" );
     ++val_;
     return *this;
 }
Ejemplo n.º 6
0
 convex_polygon(std::vector<vect> const& vertices):vertices_(vertices){ caller_error_if(vertices_.size() < 3, "Trying to construct a polygon with fewer than three vertices"); } // And there's also something wrong with a polygon where all the points are collinear, but it's more complicated to check that.