File: heavy_objects.hpp

package info (click to toggle)
boost1.90 1.90.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 593,168 kB
  • sloc: cpp: 4,190,642; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,776; makefile: 1,162; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (112 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* Classes for Boost.Flyweight key-value tests.
 *
 * Copyright 2006-2024 Joaquin M Lopez Munoz.
 * 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)
 *
 * See http://www.boost.org/libs/flyweight for library home page.
 */

#ifndef BOOST_FLYWEIGHT_TEST_HEAVY_OBJECTS_HPP
#define BOOST_FLYWEIGHT_TEST_HEAVY_OBJECTS_HPP

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/noncopyable.hpp>
#include <iosfwd>
#include <string>

struct texture
{
  texture(const std::string& str_=""):str(str_){}

  friend bool operator==(
    const texture& x,const texture& y){return x.str==y.str;}
  friend bool operator< (
    const texture& x,const texture& y){return x.str< y.str;}
  friend bool operator!=(
    const texture& x,const texture& y){return x.str!=y.str;}
  friend bool operator> (
    const texture& x,const texture& y){return x.str> y.str;}
  friend bool operator>=(
    const texture& x,const texture& y){return x.str>=y.str;}
  friend bool operator<=(
    const texture& x,const texture& y){return x.str<=y.str;}

  friend std::ostream& operator<<(std::ostream& os,const texture& x)
  {
    return os<<x.str;
  }

  friend std::istream& operator>>(std::istream& is,texture& x)
  {
    return is>>x.str;
  }

  std::string str;
};

struct from_texture_to_string
{
  const std::string& operator()(const texture& x)const{return x.str;}
};

struct factorization:private boost::noncopyable
{
  factorization(int n_=0):n(n_){}

  friend bool operator==(
    const factorization& x,const factorization& y){return x.n==y.n;}
  friend bool operator< (
    const factorization& x,const factorization& y){return x.n< y.n;}
  friend bool operator!=(
    const factorization& x,const factorization& y){return x.n!=y.n;}
  friend bool operator> (
    const factorization& x,const factorization& y){return x.n> y.n;}
  friend bool operator>=(
    const factorization& x,const factorization& y){return x.n>=y.n;}
  friend bool operator<=(
    const factorization& x,const factorization& y){return x.n<=y.n;}

  friend std::ostream& operator<<(std::ostream& os,const factorization& x)
  {
    return os<<x.n;
  }

  friend std::istream& operator>>(std::istream& is,factorization& x)
  {
    return is>>x.n;
  }

  int n;
};

#if !defined(BOOST_NO_EXCEPTIONS)
struct throwing_value_exception{};

struct throwing_value
{
  throwing_value(bool does_throw_=true):n(0),does_throw(does_throw_){}

  throwing_value(const throwing_value& x):n(x.n),does_throw(x.does_throw)
  {
    if(does_throw)throw throwing_value_exception();
  }

  throwing_value(int){throw throwing_value_exception();}

  int  n;
  bool does_throw;
};

struct from_throwing_value_to_int
{
  const int& operator()(const throwing_value& x)const{return x.n;}
};
#endif

#endif