├── .appveyor.yml ├── .codecov.yml ├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── build.jam ├── doc ├── LvaluePropertyMap.html ├── ReadWritePropertyMap.html ├── ReadablePropertyMap.html ├── WritablePropertyMap.html ├── associative_property_map.html ├── compose_property_map.html ├── const_assoc_property_map.html ├── dynamic_property_map.html ├── dynamic_property_map.rst ├── function_property_map.html ├── identity_property_map.html ├── iterator_property_map.html ├── property_map.html ├── ref_property_map.html ├── shared_array_property_map.html ├── static_property_map.html ├── transform_value_property_map.html └── vector_property_map.html ├── example ├── Jamfile.v2 ├── compose_property_map_example.cpp ├── example1.cpp ├── example2.cpp └── example3.cpp ├── include └── boost │ └── property_map │ ├── compose_property_map.hpp │ ├── dynamic_property_map.hpp │ ├── function_property_map.hpp │ ├── property_map.hpp │ ├── property_map_iterator.hpp │ ├── shared_array_property_map.hpp │ ├── transform_value_property_map.hpp │ └── vector_property_map.hpp ├── index.html ├── meta └── libraries.json └── test ├── Jamfile.v2 ├── cmake_test ├── CMakeLists.txt └── main.cpp ├── compose_property_map_test.cpp ├── dynamic_properties_test.cpp ├── function_property_map_test.cpp ├── property_map_cc.cpp ├── suppressions.txt └── transform_value_property_map_test.cpp /.appveyor.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2017 Peter Dimov 2 | # Copyright 2017 - 2019 James E. King III 3 | # Copyright 2019 - 2021 Alexander Grund 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 6 | 7 | # 8 | # Generic Appveyor build script for boostorg repositories 9 | # See: https://github.com/boostorg/boost-ci/ 10 | # 11 | # Instructions for customizing this script for your library: 12 | # 13 | # 1. Customize the compilers and language levels you want. 14 | # 2. If you have more than include/, src/, test/, example/, examples/, 15 | # benchmark/ or tools/ directories, set the environment variable DEPINST. 16 | # For example if your build uses code in "bench/" and "fog/" directories: 17 | # - DEPINST: --include bench --include fog 18 | # 3. Enable pull request builds in your boostorg/ account. 19 | # 20 | # That's it - the script will do everything else for you. 21 | # 22 | 23 | version: 1.0.{build}-{branch} 24 | 25 | shallow_clone: true 26 | 27 | branches: 28 | only: 29 | - master 30 | - develop 31 | - /bugfix\/.*/ 32 | - /feature\/.*/ 33 | - /fix\/.*/ 34 | - /pr\/.*/ 35 | 36 | skip_commits: 37 | files: 38 | - LICENSE 39 | - meta/* 40 | - README.md 41 | 42 | matrix: 43 | fast_finish: false 44 | # Adding MAYFAIL to any matrix job allows it to fail but the build stays green: 45 | allow_failures: 46 | - MAYFAIL: true 47 | 48 | environment: 49 | global: 50 | B2_CI_VERSION: 1 51 | GIT_FETCH_JOBS: 4 52 | # see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties 53 | # to use the default for a given environment, comment it out; recommend you build debug and release however: 54 | # on Windows it is important to exercise all the possibilities, especially shared vs static, however most 55 | # libraries that care about this exercise it in their Jamfiles... 56 | B2_ADDRESS_MODEL: 32,64 57 | B2_LINK: shared,static 58 | # B2_THREADING: threading=multi,single 59 | B2_VARIANT: release 60 | 61 | matrix: 62 | - FLAVOR: Visual Studio 2017 C++2a Strict 63 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 64 | B2_CXXFLAGS: -permissive- 65 | B2_CXXSTD: 2a 66 | B2_TOOLSET: msvc-14.1 67 | 68 | - FLAVOR: Visual Studio 2017 C++14/17 69 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 70 | B2_CXXSTD: 14,17 71 | B2_TOOLSET: msvc-14.1 72 | 73 | - FLAVOR: cygwin (32-bit) 74 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 75 | ADDPATH: C:\cygwin\bin; 76 | B2_ADDRESS_MODEL: 32 77 | B2_CXXSTD: 11,14,1z 78 | B2_TOOLSET: gcc 79 | 80 | - FLAVOR: cygwin (64-bit) 81 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 82 | ADDPATH: C:\cygwin64\bin; 83 | B2_ADDRESS_MODEL: 64 84 | B2_CXXSTD: 11,14,1z 85 | B2_TOOLSET: gcc 86 | 87 | install: 88 | - git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned 89 | # Copy ci folder if not testing Boost.CI 90 | - if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci 91 | - rmdir /s /q C:\boost-ci-cloned 92 | - ci\appveyor\install.bat 93 | 94 | build: off 95 | 96 | test_script: ci\build.bat 97 | 98 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 - 2021 Alexander Grund 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 4 | # 5 | # Sample codecov configuration file. Edit as required 6 | 7 | codecov: 8 | max_report_age: off 9 | require_ci_to_pass: yes 10 | notify: 11 | # Increase this if you have multiple coverage collection jobs 12 | after_n_builds: 2 13 | wait_for_ci: yes 14 | 15 | parsers: 16 | gcov: 17 | branch_detection: 18 | conditional: yes 19 | loop: yes 20 | method: no 21 | macro: no 22 | 23 | # Change how pull request comments look 24 | comment: 25 | layout: "reach,diff,flags,files,footer" 26 | 27 | # Ignore specific files or folders. Glob patterns are supported. 28 | # See https://docs.codecov.com/docs/ignoring-paths 29 | ignore: 30 | - libs/property_map/test/ 31 | - test/ 32 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto !eol svneol=native#text/plain 2 | *.gitattributes text svneol=native#text/plain 3 | 4 | # Scriptish formats 5 | *.bat text svneol=native#text/plain 6 | *.bsh text svneol=native#text/x-beanshell 7 | *.cgi text svneol=native#text/plain 8 | *.cmd text svneol=native#text/plain 9 | *.js text svneol=native#text/javascript 10 | *.php text svneol=native#text/x-php 11 | *.pl text svneol=native#text/x-perl 12 | *.pm text svneol=native#text/x-perl 13 | *.py text svneol=native#text/x-python 14 | *.sh eol=lf svneol=LF#text/x-sh 15 | configure eol=lf svneol=LF#text/x-sh 16 | 17 | # Image formats 18 | *.bmp binary svneol=unset#image/bmp 19 | *.gif binary svneol=unset#image/gif 20 | *.ico binary svneol=unset#image/ico 21 | *.jpeg binary svneol=unset#image/jpeg 22 | *.jpg binary svneol=unset#image/jpeg 23 | *.png binary svneol=unset#image/png 24 | *.tif binary svneol=unset#image/tiff 25 | *.tiff binary svneol=unset#image/tiff 26 | *.svg text svneol=native#image/svg%2Bxml 27 | 28 | # Data formats 29 | *.pdf binary svneol=unset#application/pdf 30 | *.avi binary svneol=unset#video/avi 31 | *.doc binary svneol=unset#application/msword 32 | *.dsp text svneol=crlf#text/plain 33 | *.dsw text svneol=crlf#text/plain 34 | *.eps binary svneol=unset#application/postscript 35 | *.gz binary svneol=unset#application/gzip 36 | *.mov binary svneol=unset#video/quicktime 37 | *.mp3 binary svneol=unset#audio/mpeg 38 | *.ppt binary svneol=unset#application/vnd.ms-powerpoint 39 | *.ps binary svneol=unset#application/postscript 40 | *.psd binary svneol=unset#application/photoshop 41 | *.rdf binary svneol=unset#text/rdf 42 | *.rss text svneol=unset#text/xml 43 | *.rtf binary svneol=unset#text/rtf 44 | *.sln text svneol=native#text/plain 45 | *.swf binary svneol=unset#application/x-shockwave-flash 46 | *.tgz binary svneol=unset#application/gzip 47 | *.vcproj text svneol=native#text/xml 48 | *.vcxproj text svneol=native#text/xml 49 | *.vsprops text svneol=native#text/xml 50 | *.wav binary svneol=unset#audio/wav 51 | *.xls binary svneol=unset#application/vnd.ms-excel 52 | *.zip binary svneol=unset#application/zip 53 | 54 | # Text formats 55 | .htaccess text svneol=native#text/plain 56 | *.bbk text svneol=native#text/xml 57 | *.cmake text svneol=native#text/plain 58 | *.css text svneol=native#text/css 59 | *.dtd text svneol=native#text/xml 60 | *.htm text svneol=native#text/html 61 | *.html text svneol=native#text/html 62 | *.ini text svneol=native#text/plain 63 | *.log text svneol=native#text/plain 64 | *.mak text svneol=native#text/plain 65 | *.qbk text svneol=native#text/plain 66 | *.rst text svneol=native#text/plain 67 | *.sql text svneol=native#text/x-sql 68 | *.txt text svneol=native#text/plain 69 | *.xhtml text svneol=native#text/xhtml%2Bxml 70 | *.xml text svneol=native#text/xml 71 | *.xsd text svneol=native#text/xml 72 | *.xsl text svneol=native#text/xml 73 | *.xslt text svneol=native#text/xml 74 | *.xul text svneol=native#text/xul 75 | *.yml text svneol=native#text/plain 76 | boost-no-inspect text svneol=native#text/plain 77 | CHANGES text svneol=native#text/plain 78 | COPYING text svneol=native#text/plain 79 | INSTALL text svneol=native#text/plain 80 | Jamfile text svneol=native#text/plain 81 | Jamroot text svneol=native#text/plain 82 | Jamfile.v2 text svneol=native#text/plain 83 | Jamrules text svneol=native#text/plain 84 | Makefile* text svneol=native#text/plain 85 | README text svneol=native#text/plain 86 | TODO text svneol=native#text/plain 87 | 88 | # Code formats 89 | *.c text svneol=native#text/plain 90 | *.cpp text svneol=native#text/plain 91 | *.h text svneol=native#text/plain 92 | *.hpp text svneol=native#text/plain 93 | *.ipp text svneol=native#text/plain 94 | *.tpp text svneol=native#text/plain 95 | *.jam text svneol=native#text/plain 96 | *.java text svneol=native#text/plain 97 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020-2021 Peter Dimov 2 | # Copyright 2021 Andrey Semashev 3 | # Copyright 2021 Alexander Grund 4 | # Copyright 2022-2024 James E. King III 5 | # 6 | # Distributed under the Boost Software License, Version 1.0. 7 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 8 | --- 9 | name: CI 10 | 11 | on: 12 | pull_request: 13 | push: 14 | branches: 15 | - master 16 | - develop 17 | - bugfix/** 18 | - feature/** 19 | - fix/** 20 | - pr/** 21 | paths-ignore: 22 | - LICENSE 23 | - meta/** 24 | - README.md 25 | 26 | concurrency: 27 | group: ${{format('{0}:{1}', github.repository, github.ref)}} 28 | cancel-in-progress: true 29 | 30 | env: 31 | GIT_FETCH_JOBS: 8 32 | NET_RETRY_COUNT: 5 33 | B2_CI_VERSION: 1 34 | B2_VARIANT: debug,release 35 | B2_LINK: shared,static 36 | LCOV_BRANCH_COVERAGE: 0 37 | 38 | jobs: 39 | posix: 40 | defaults: 41 | run: 42 | shell: bash 43 | 44 | strategy: 45 | fail-fast: false 46 | matrix: 47 | include: 48 | # linux, gcc 49 | - { compiler: gcc-7, cxxstd: '11,14,17', os: ubuntu-20.04 } 50 | - { compiler: gcc-8, cxxstd: '11,14,17,2a', os: ubuntu-20.04 } 51 | - { compiler: gcc-9, cxxstd: '11,14,17,2a', os: ubuntu-20.04 } 52 | - { compiler: gcc-10, cxxstd: '11,14,17,20', os: ubuntu-20.04 } 53 | - { compiler: gcc-11, cxxstd: '11,14,17,20', os: ubuntu-20.04 } 54 | - { compiler: gcc-12, cxxstd: '11,14,17,20', os: ubuntu-22.04 } 55 | - { compiler: gcc-13, cxxstd: '11,14,17,20,2b', os: ubuntu-22.04 } 56 | - { compiler: gcc-14, cxxstd: '11,14,17,20,2b', os: ubuntu-24.04 } 57 | - { name: GCC w/ sanitizers, sanitize: yes, 58 | compiler: gcc-13, cxxstd: '11,14,17,20', os: ubuntu-22.04 } 59 | - { name: Collect coverage, coverage: yes, 60 | compiler: gcc-12, cxxstd: '11', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '32,64' } 61 | 62 | # linux, clang 63 | - { compiler: clang-9, cxxstd: '11,14,17,2a', os: ubuntu-20.04 } 64 | - { compiler: clang-10, cxxstd: '11,14,17,20', os: ubuntu-20.04 } 65 | - { compiler: clang-11, cxxstd: '11,14,17,20', os: ubuntu-20.04 } 66 | - { compiler: clang-12, cxxstd: '11,14,17,20', os: ubuntu-20.04 } 67 | # Clang isn't compatible with libstdc++-13, so use the slightly older one 68 | - { compiler: clang-13, cxxstd: '11,14,17,20', os: ubuntu-22.04, install: 'clang-13 g++-12', gcc_toolchain: 12 } 69 | - { compiler: clang-14, cxxstd: '11,14,17,20', os: ubuntu-22.04, install: 'clang-14 g++-12', gcc_toolchain: 12 } 70 | - { compiler: clang-15, cxxstd: '11,14,17,20', os: ubuntu-22.04, install: 'clang-15 g++-12', gcc_toolchain: 12 } 71 | - { compiler: clang-16, cxxstd: '11,14,17,20,2b', os: ubuntu-24.04 } 72 | # https://github.com/llvm/llvm-project/issues/59827: disabled 2b/23 for clang-17 with libstdc++13 in 24.04 73 | - { compiler: clang-17, cxxstd: '11,14,17,20', os: ubuntu-24.04 } 74 | - { compiler: clang-18, cxxstd: '11,17,20,23,2c', os: ubuntu-24.04 } 75 | 76 | # linux, libc++ 77 | - { name: Clang w/ sanitizers, sanitize: yes, 78 | compiler: clang-12, cxxstd: '11,14,17,20', os: ubuntu-20.04, stdlib: 'libc++', install: 'clang-12 libc++-12-dev libc++abi-12-dev' } 79 | 80 | - { name: MacOS w/ clang and sanitizers, 81 | compiler: clang, cxxstd: '11,14,17,20,2b', os: macos-13, sanitize: yes } 82 | - { compiler: clang, cxxstd: '11,14,17,20,2b', os: macos-14 } 83 | - { compiler: clang, cxxstd: '11,14,17,20,2b', os: macos-15 } 84 | 85 | # Coverity Scan 86 | # requires two github secrets in repo to activate; see ci/github/coverity.sh 87 | # does not run on pull requests, only on pushes into develop and master 88 | - { name: Coverity, coverity: yes, 89 | compiler: clang-12, cxxstd: '17', os: ubuntu-20.04, ccache: no } 90 | 91 | # multiarch (bigendian testing) - does not support coverage yet 92 | - { name: Big-endian, multiarch: yes, 93 | compiler: clang, cxxstd: '17', os: ubuntu-22.04, ccache: no, distro: fedora, edition: 34, arch: s390x } 94 | 95 | timeout-minutes: 120 96 | runs-on: ${{matrix.os}} 97 | env: {B2_USE_CCACHE: 1} 98 | 99 | steps: 100 | - name: Setup environment 101 | run: | 102 | if [ -f "/etc/debian_version" ]; then 103 | echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV 104 | export DEBIAN_FRONTEND=noninteractive 105 | fi 106 | if [ -n "${{matrix.container}}" ] && [ -f "/etc/debian_version" ]; then 107 | apt-get -o Acquire::Retries=$NET_RETRY_COUNT update 108 | apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common curl 109 | # Need (newer) git, and the older Ubuntu container may require requesting the key manually using port 80 110 | curl -sSL --retry ${NET_RETRY_COUNT:-5} 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xE1DD270288B4E6030699E45FA1715D88E1DF1F24' | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/git-core_ubuntu_ppa.gpg 111 | for i in {1..${NET_RETRY_COUNT:-3}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done 112 | apt-get -o Acquire::Retries=$NET_RETRY_COUNT update 113 | osver=$(lsb_release -sr | cut -f1 -d.) 114 | pkgs="g++ git xz-utils" 115 | # Ubuntu 22+ has only Python 3 in the repos 116 | if [ -n "$osver" ] && [ "$osver" -ge "22" ]; then 117 | pkgs+=" python-is-python3 libpython3-dev" 118 | else 119 | pkgs+=" python libpython-dev" 120 | fi 121 | apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs 122 | fi 123 | # For jobs not compatible with ccache, use "ccache: no" in the matrix 124 | if [[ "${{ matrix.ccache }}" == "no" ]]; then 125 | echo "B2_USE_CCACHE=0" >> $GITHUB_ENV 126 | fi 127 | if [[ "${{ matrix.sanitize }}" == "yes" ]]; then 128 | echo "LSAN_OPTIONS=suppressions=${GITHUB_WORKSPACE}/test/suppressions.txt" >> $GITHUB_ENV 129 | fi 130 | git config --global pack.threads 0 131 | if [[ "${{matrix.container}}" == "ubuntu:1"* ]]; then 132 | # Node 20 doesn't work with Ubuntu 16/18 glibc: https://github.com/actions/checkout/issues/1590 133 | curl -sL https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 134 | fi 135 | 136 | - uses: actions/checkout@v4 137 | with: 138 | # For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary' 139 | fetch-depth: ${{ matrix.coverage && '0' || '1' }} 140 | 141 | - name: Cache ccache 142 | uses: actions/cache@v4 143 | if: env.B2_USE_CCACHE 144 | with: 145 | path: ~/.ccache 146 | key: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}} 147 | restore-keys: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}- 148 | 149 | - name: Fetch Boost.CI 150 | uses: actions/checkout@v4 151 | with: 152 | repository: boostorg/boost-ci 153 | ref: master 154 | path: boost-ci-cloned 155 | 156 | - name: Get CI scripts folder 157 | run: | 158 | # Copy ci folder if not testing Boost.CI 159 | [[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci . 160 | rm -rf boost-ci-cloned 161 | 162 | - name: Install packages 163 | if: startsWith(matrix.os, 'ubuntu') 164 | run: | 165 | SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}") 166 | SOURCES=("${{join(matrix.sources, '" "')}}") 167 | # Add this by default 168 | SOURCE_KEYS+=('http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x1E9377A2BA9EF27F') 169 | SOURCES+=(ppa:ubuntu-toolchain-r/test) 170 | 171 | ci/add-apt-keys.sh "${SOURCE_KEYS[@]}" 172 | # Initial update before adding sources required to get e.g. keys 173 | sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update 174 | ci/add-apt-repositories.sh "${SOURCES[@]}" 175 | 176 | sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update 177 | if [[ -z "${{matrix.install}}" ]]; then 178 | pkgs="${{matrix.compiler}}" 179 | pkgs="${pkgs/gcc-/g++-}" 180 | else 181 | pkgs="${{matrix.install}}" 182 | fi 183 | sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs 184 | 185 | - name: Setup GCC Toolchain 186 | if: matrix.gcc_toolchain 187 | run: | 188 | GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain" 189 | echo "GCC_TOOLCHAIN_ROOT=$GCC_TOOLCHAIN_ROOT" >> $GITHUB_ENV 190 | if ! command -v dpkg-architecture; then 191 | apt-get install -y dpkg-dev 192 | fi 193 | MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)" 194 | mkdir -p "$GCC_TOOLCHAIN_ROOT" 195 | ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include" 196 | ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin" 197 | mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET" 198 | ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" 199 | 200 | - name: Setup multiarch 201 | if: matrix.multiarch 202 | env: 203 | BDDE_DISTRO: ${{matrix.distro}} 204 | BDDE_EDITION: ${{matrix.edition}} 205 | BDDE_ARCH: ${{matrix.arch}} 206 | run: ci/github/setup_bdde.sh 207 | 208 | - name: Setup Boost 209 | env: 210 | B2_ADDRESS_MODEL: ${{matrix.address-model}} 211 | B2_COMPILER: ${{matrix.compiler}} 212 | B2_CXXSTD: ${{matrix.cxxstd}} 213 | B2_SANITIZE: ${{matrix.sanitize}} 214 | B2_STDLIB: ${{matrix.stdlib}} 215 | # More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys. 216 | # B2_DEFINES: ${{matrix.defines}} 217 | # Variables set here (to non-empty) will override the top-level environment variables, e.g. 218 | # B2_VARIANT: ${{matrix.variant}} 219 | # Set the (B2) target(s) to build, defaults to the test folder of the current library 220 | # Can alternatively be done like this in the build step or in the build command of the build step, e.g. `run: B2_TARGETS=libs/$SELF/doc ci/build.sh` 221 | # B2_TARGETS: libs/foo/test//bar 222 | run: source ci/github/install.sh 223 | 224 | - name: Setup coverage collection 225 | if: matrix.coverage 226 | run: ci/github/codecov.sh "setup" 227 | 228 | - name: Run tests 229 | if: '!matrix.coverity' 230 | run: ci/build.sh 231 | 232 | - name: Upload coverage 233 | if: matrix.coverage 234 | run: ci/codecov.sh "upload" 235 | env: 236 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 237 | 238 | - name: Run coverity 239 | if: matrix.coverity && github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'master') 240 | run: ci/github/coverity.sh 241 | env: 242 | COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} 243 | COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 244 | 245 | windows: 246 | defaults: 247 | run: 248 | shell: cmd 249 | strategy: 250 | fail-fast: false 251 | matrix: 252 | include: 253 | - { toolset: msvc-14.0, cxxstd: '14,latest', addrmd: '32,64', os: windows-2019 } 254 | - { toolset: msvc-14.2, cxxstd: '14,17,20', addrmd: '32,64', os: windows-2019 } 255 | - { toolset: msvc-14.3, cxxstd: '14,17,20,latest',addrmd: '32,64', os: windows-2022 } 256 | - { name: Collect coverage, coverage: yes, 257 | toolset: msvc-14.3, cxxstd: 'latest', addrmd: '64', os: windows-2022 } 258 | - { toolset: clang-win, cxxstd: '14,17,latest', addrmd: '32,64', os: windows-2022 } 259 | - { toolset: gcc, cxxstd: '11,14,17,2a', addrmd: '64', os: windows-2019 } 260 | 261 | runs-on: ${{matrix.os}} 262 | 263 | steps: 264 | - uses: actions/checkout@v4 265 | 266 | - name: Fetch Boost.CI 267 | uses: actions/checkout@v4 268 | with: 269 | repository: boostorg/boost-ci 270 | ref: master 271 | path: boost-ci-cloned 272 | - name: Get CI scripts folder 273 | run: | 274 | REM Copy ci folder if not testing Boost.CI 275 | if "%GITHUB_REPOSITORY%" == "%GITHUB_REPOSITORY:boost-ci=%" xcopy /s /e /q /i /y boost-ci-cloned\ci .\ci 276 | rmdir /s /q boost-ci-cloned 277 | 278 | - name: Setup Boost 279 | run: ci\github\install.bat 280 | 281 | - name: Run tests 282 | if: '!matrix.coverage' 283 | run: ci\build.bat 284 | env: 285 | B2_TOOLSET: ${{matrix.toolset}} 286 | B2_CXXSTD: ${{matrix.cxxstd}} 287 | B2_ADDRESS_MODEL: ${{matrix.addrmd}} 288 | 289 | - name: Collect coverage 290 | shell: powershell 291 | if: matrix.coverage 292 | run: ci\opencppcoverage.ps1 293 | env: 294 | B2_TOOLSET: ${{matrix.toolset}} 295 | B2_CXXSTD: ${{matrix.cxxstd}} 296 | B2_ADDRESS_MODEL: ${{matrix.addrmd}} 297 | 298 | - name: Upload coverage 299 | if: matrix.coverage 300 | uses: codecov/codecov-action@v5 301 | with: 302 | disable_search: true 303 | fail_ci_if_error: true 304 | files: __out/cobertura.xml 305 | name: github-actions 306 | token: ${{secrets.CODECOV_TOKEN}} 307 | verbose: true 308 | 309 | MSYS2: 310 | defaults: 311 | run: 312 | shell: msys2 {0} 313 | strategy: 314 | fail-fast: false 315 | matrix: 316 | include: 317 | - { sys: MINGW32, compiler: gcc, cxxstd: '11,17,20' } 318 | - { sys: MINGW64, compiler: gcc, cxxstd: '11,17,20' } 319 | 320 | runs-on: windows-latest 321 | 322 | steps: 323 | - uses: actions/checkout@v4 324 | 325 | - name: Setup MSYS2 environment 326 | uses: msys2/setup-msys2@v2 327 | with: 328 | msystem: ${{matrix.sys}} 329 | update: true 330 | install: git python 331 | pacboy: gcc:p cmake:p ninja:p 332 | 333 | - name: Fetch Boost.CI 334 | uses: actions/checkout@v4 335 | with: 336 | repository: boostorg/boost-ci 337 | ref: master 338 | path: boost-ci-cloned 339 | - name: Get CI scripts folder 340 | run: | 341 | # Copy ci folder if not testing Boost.CI 342 | [[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci . 343 | rm -rf boost-ci-cloned 344 | 345 | - name: Setup Boost 346 | env: 347 | B2_COMPILER: ${{matrix.compiler}} 348 | B2_CXXSTD: ${{matrix.cxxstd}} 349 | B2_SANITIZE: ${{matrix.sanitize}} 350 | B2_STDLIB: ${{matrix.stdlib}} 351 | run: ci/github/install.sh 352 | 353 | - name: Run tests 354 | run: ci/build.sh 355 | 356 | # Run also the CMake tests to avoid having to setup another matrix for CMake on MSYS 357 | - name: Run CMake tests 358 | run: | 359 | cd "$BOOST_ROOT" 360 | mkdir __build_cmake_test__ && cd __build_cmake_test__ 361 | cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DBoost_VERBOSE=ON .. 362 | cmake --build . --target tests --config Debug -j$B2_JOBS 363 | ctest --output-on-failure --build-config Debug 364 | 365 | CMake: 366 | defaults: 367 | run: 368 | shell: bash 369 | 370 | strategy: 371 | fail-fast: false 372 | matrix: 373 | include: 374 | - { os: ubuntu-20.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' } 375 | - { os: ubuntu-20.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' } 376 | - { os: windows-2019, build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' } 377 | - { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' } 378 | 379 | timeout-minutes: 120 380 | runs-on: ${{matrix.os}} 381 | 382 | steps: 383 | - uses: actions/checkout@v4 384 | - name: Fetch Boost.CI 385 | uses: actions/checkout@v4 386 | with: 387 | repository: boostorg/boost-ci 388 | ref: master 389 | path: boost-ci-cloned 390 | - name: Get CI scripts folder 391 | run: | 392 | # Copy ci folder if not testing Boost.CI 393 | [[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci . 394 | rm -rf boost-ci-cloned 395 | - name: Setup Boost 396 | env: {B2_DONT_BOOTSTRAP: 1} 397 | run: source ci/github/install.sh 398 | 399 | - name: Run CMake tests 400 | run: | 401 | cd "$BOOST_ROOT" 402 | mkdir __build_cmake_test__ && cd __build_cmake_test__ 403 | cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON .. 404 | cmake --build . --target tests --config ${{matrix.build_type}} -j$B2_JOBS 405 | ctest --output-on-failure --build-config ${{matrix.build_type}} 406 | 407 | - name: Run CMake subdir tests 408 | run: | 409 | cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder 410 | [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_subdir_test" 411 | cd "$cmake_test_folder" 412 | mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__ 413 | cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=OFF -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} .. 414 | cmake --build . --config ${{matrix.build_type}} -j$B2_JOBS 415 | ctest --output-on-failure --build-config ${{matrix.build_type}} 416 | 417 | - name: Install Library 418 | run: | 419 | cd "$BOOST_ROOT" 420 | mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__ 421 | cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON .. 422 | cmake --build . --target install --config ${{matrix.build_type}} -j$B2_JOBS 423 | - name: Run CMake install tests 424 | run: | 425 | cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder 426 | [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_install_test" 427 | cd "$cmake_test_folder" 428 | mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__ 429 | cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_PREFIX_PATH=~/.local .. 430 | cmake --build . --config ${{matrix.build_type}} -j$B2_JOBS 431 | ctest --output-on-failure --build-config ${{matrix.build_type}} 432 | 433 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated by `boostdep --cmake property_map` 2 | # Copyright 2020 Peter Dimov 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.16) 7 | 8 | project(boost_property_map VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_property_map INTERFACE) 11 | add_library(Boost::property_map ALIAS boost_property_map) 12 | 13 | target_include_directories(boost_property_map INTERFACE include) 14 | 15 | target_link_libraries(boost_property_map 16 | INTERFACE 17 | Boost::any 18 | Boost::assert 19 | Boost::concept_check 20 | Boost::config 21 | Boost::core 22 | Boost::function 23 | Boost::iterator 24 | Boost::lexical_cast 25 | Boost::mpl 26 | Boost::smart_ptr 27 | Boost::static_assert 28 | Boost::throw_exception 29 | Boost::type_traits 30 | Boost::utility 31 | ) 32 | 33 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 34 | 35 | add_subdirectory(test) 36 | 37 | endif() 38 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PropertyMap, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), 2 | defines a general purpose interface for mapping key objects to corresponding value objects, thereby hiding the details of how the mapping is implemented from algorithms. 3 | 4 | ### License 5 | 6 | Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 7 | 8 | ### Properties 9 | 10 | * C++11 11 | * Header-only 12 | 13 | ### Build Status 14 | 15 | 16 | | Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | 17 | | :-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | 18 | | [`master`](https://github.com/boostorg/property_map/tree/master) | [![Build Status](https://github.com/boostorg/property_map/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/property_map/actions?query=branch:master) | [![Build status](https://ci.appveyor.com/api/projects/status/eof5tntsuwagfqis/branch/master?svg=true)](https://ci.appveyor.com/project/cppalliance/property-map/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15841/badge.svg)](https://scan.coverity.com/projects/boostorg-property_map) | [![codecov](https://codecov.io/gh/boostorg/property_map/branch/master/graph/badge.svg?token=IAO17unWyC)](https://codecov.io/gh/boostorg/property_map/tree/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/property_map.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://www.boost.org/doc/libs/master/libs/property_map) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://www.boost.org/development/tests/master/developer/property_map.html) 19 | | [`develop`](https://github.com/boostorg/property_map/tree/develop) | [![Build Status](https://github.com/boostorg/property_map/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/property_map/actions?query=branch:develop) | [![Build status](https://ci.appveyor.com/api/projects/status/eof5tntsuwagfqis/branch/develop?svg=true)](https://ci.appveyor.com/project/cppalliance/property-map/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15841/badge.svg)](https://scan.coverity.com/projects/boostorg-property_map) | [![codecov](https://codecov.io/gh/boostorg/property_map/branch/develop/graph/badge.svg?token=IAO17unWyC)](https://codecov.io/gh/boostorg/property_map/tree/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/property_map.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](https://www.boost.org/doc/libs/develop/libs/property_map) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://www.boost.org/development/tests/develop/developer/property_map.html) 20 | 21 | ### Directories 22 | 23 | | Name | Purpose | 24 | | ----------- | ------------------------------ | 25 | | `doc` | documentation | 26 | | `example` | examples | 27 | | `include` | headers | 28 | | `test` | unit tests | 29 | 30 | ### More information 31 | 32 | * [Ask questions](https://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-property_map) 33 | * [Report bugs](https://github.com/boostorg/property_map/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. 34 | * Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 35 | * Discussions about the library are held on the [Boost developers mailing list](https://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](https://www.boost.org/community/policy.html) before posting and add the `[property_map]` tag at the beginning of the subject line. 36 | 37 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | constant boost_dependencies : 9 | /boost/any//boost_any 10 | /boost/assert//boost_assert 11 | /boost/concept_check//boost_concept_check 12 | /boost/config//boost_config 13 | /boost/core//boost_core 14 | /boost/function//boost_function 15 | /boost/iterator//boost_iterator 16 | /boost/lexical_cast//boost_lexical_cast 17 | /boost/mpl//boost_mpl 18 | /boost/smart_ptr//boost_smart_ptr 19 | /boost/static_assert//boost_static_assert 20 | /boost/throw_exception//boost_throw_exception 21 | /boost/type_index//boost_type_index 22 | /boost/type_traits//boost_type_traits 23 | /boost/utility//boost_utility ; 24 | 25 | project /boost/property_map 26 | : common-requirements 27 | include 28 | ; 29 | 30 | explicit 31 | [ alias boost_property_map : : : : $(boost_dependencies) ] 32 | [ alias all : boost_property_map example test ] 33 | ; 34 | 35 | call-if : boost-library property_map 36 | ; 37 | 38 | -------------------------------------------------------------------------------- /doc/LvaluePropertyMap.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | LvaluePropertyMap 11 | 13 | C++ Boost 15 | 16 |
17 | 18 |

19 | LvaluePropertyMap 20 |

21 | 22 | The LvaluePropertyMap provides operator[] and function get() for accessing a 23 | reference to a value object. The return type refines that of function get()in ReadablePropertyMap; it can only be a reference (for a mutable LvaluePropertyMap) or a const reference (for a non-mutable LvaluePropertyMap). 25 | 26 |

Refinement of

27 | 28 | ReadablePropertyMap 29 | for non-mutable or ReadWritePropertyMap for mutable property map. 30 | 31 |

Notation

32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
PMapA type that is a model of LvaluePropertyMap.
pmapAn object of type PMap.
keyAn object of type boost::property_traits<PMap>::key_type.
48 | 49 | 50 |

Associated Types

51 | 52 | 53 | 54 | 55 | 56 | 57 | 61 | 62 | 63 | 64 | 66 | 70 | 71 | 72 |
Reference Typeboost::property_traits<PMap>::reference 58 | The reference type, which must be a reference or const reference to 59 | the value type of the property map. 60 |
Property Map Category 65 | boost::property_traits<PMap>::category 67 | The category of the property: a type convertible to 68 | boost::lvalue_property_map_tag. 69 |
73 | 74 |

Valid Expressions

75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 89 | 90 | 91 |
NameExpressionReturn TypeDescription
Access Property Value pmap[key] 86 | value_type& for mutable, const value_type& 87 | otherwise. 88 | Obtain a reference to the value associated with key.
92 | 93 |

Concept Checking Class

94 | 95 |
  template <class PMap, class Key>
 96 |   struct LvaluePropertyMapConcept
 97 |   {
 98 |     typedef typename property_traits<PMap>::category Category;
 99 |     typedef boost::lvalue_property_map_tag LvalueTag;
100 |     typedef const typename property_traits<PMap>::value_type& const_reference;
101 |     void constraints() {
102 |       function_requires< ReadWritePropertyMapConcept<PMap, Key> >();
103 |       function_requires< ConvertibleConcept<Category, LvalueTag> >();
104 | 
105 |       const_reference ref = pmap[k];
106 |     }
107 |     PMap pmap;
108 |     Key k;
109 |   };
110 | 
111 |   template <class PMap, class Key>
112 |   struct Mutable_LvaluePropertyMapConcept
113 |   {
114 |     typedef typename property_traits<PMap>::category Category;
115 |     typedef boost::lvalue_property_map_tag LvalueTag;
116 |     typedef typename property_traits<PMap>::value_type& reference;
117 |     void constraints() { 
118 |       function_requires< ReadWritePropertyMapConcept<PMap, Key> >();
119 |       function_requires<ConvertibleConcept<Category, LvalueTag> >();
120 | 
121 |       reference ref = pmap[k];
122 |     }
123 |     PMap pmap;
124 |     Key k;
125 |   };
126 | 127 |

See Also

128 | 129 | Property map concepts 130 | 131 | 132 |
133 |
134 | 135 | 136 |
Copyright © 2000 137 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) 138 |
139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /doc/ReadWritePropertyMap.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Read Write Property Map 11 | 13 | C++ Boost 15 | 16 |
17 | 18 |

19 | 20 |
21 | Read/Write Property Map 22 |

23 | 24 | A Read/Write Property Map can be used to read property values via 25 | the get() function and can be used to write property values 26 | via the put() function. 27 | 28 |

Refinement of

29 | 30 | Readable Property Map 31 | and 32 | Writable Property Map 33 | 34 | 35 | 36 |

Notation

37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
PMapA type that is a model of Read/Write Property Map.
45 | 46 |

Associated Types

47 | 48 | 49 | 50 | 51 | 53 | 57 | 58 | 59 |
Property Map Category 52 | boost::property_traits<PMap>::category 54 | The category of the property map must be a type convertible to 55 | read_write_property_map_tag. 56 |
60 | 61 | 62 |

Concept Checking Class

63 | 64 |
65 |   template <class PMap, class Key>
66 |   struct ReadWritePropertyMapConcept
67 |   {
68 |     typedef typename property_traits<PMap>::category Category;
69 |     typedef boost::read_write_property_map_tag ReadWriteTag;
70 |     void constraints() {
71 |       function_requires< ReadablePropertyMapConcept<PMap, Key> >();
72 |       function_requires< WritablePropertyMapConcept<PMap, Key> >();
73 |       function_requires< ConvertibleConcept<Category, ReadWriteTag> >();
74 |     }
75 |   };
76 | 
77 | 78 |

See Also

79 | 80 | Property map concepts 81 | 82 | 83 |
84 |
85 | 86 | 87 |
Copyright © 2000 88 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) 89 |
90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /doc/ReadablePropertyMap.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Readable Property Map 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 | Readable Property Map 21 |

22 | 23 | A Readable Property Map provides read-access to the value associated with a given key via a call to the get() function. 24 | The return type of the get()function is either the value_type of the property map or a (const or non-const) reference to that type. 25 | 26 |

Refinement of

27 | 28 | Copy Constructible 29 | 30 |

Notation

31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
PMapA type that is a model of Readable Property Map.
pmapAn object of type PMap.
keyAn object of type boost::property_traits<PMap>::key_type.
47 | 48 |

Associated Types

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 64 | 65 | 66 | 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 83 | 84 | 85 |
Value Typeboost::property_traits<PMap>::value_typeThe type of the property.
Reference Typeboost::property_traits<PMap>::reference 62 | A type that is convertible to the value type. 63 |
Key Typeboost::property_traits<PMap>::key_type 70 | The type of the key object used to look up the property. The property 71 | map may be templated on the key type, in which case this 72 | typedef can be void. 73 |
Property Map Categoryboost::property_traits<PMap>::category 80 | The category of the property: a type convertible to 81 | readable_property_map_tag. 82 |
86 | 87 |

Valid Expressions

88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |
NameExpressionReturn TypeDescription
Get Property Value get(pmap, key)referenceLookup the value associated with key.
102 | 103 |

Concept Checking Class

104 | 105 |
  template <class PMap, class Key>
106 |   struct ReadablePropertyMapConcept
107 |   {
108 |     typedef typename property_traits<PMap>::key_type key_type;
109 |     typedef typename property_traits<PMap>::category Category;
110 |     typedef boost::readable_property_map_tag ReadableTag;
111 |     void constraints() {
112 |       function_requires< ConvertibleConcept<Category, ReadableTag> >();
113 | 
114 |       val = get(pmap, k);
115 |     }
116 |     PMap pmap;
117 |     Key k;
118 |     typename property_traits<PMap>::value_type val;
119 |   };
120 | 121 |

See Also

122 | 123 | Property map concepts 124 | 125 |

Design Notes

126 | 127 | At various times the name "read-only" was considered for 128 | this concept. However, that name is inappropriate because concepts are 129 | inherently positive, not negative. This becomes obvious when we define 130 | the Read Write Property Map, which refines both the Readable Property 131 | Map and the Writable Property Map concept. It would not make much 132 | sense to combine "read-only" and "write-only" 133 | concepts! 134 | 135 |
136 |
137 | 138 | 139 |
Copyright © 2000 140 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) 141 |
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /doc/WritablePropertyMap.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | WritablePropertyMap 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 | Writable Property Map 21 |

22 | 23 | A Writable Property Map has the capability of setting the value 24 | object associated with the given key object via the put() 25 | function. 26 | 27 |

Refinement of

28 | 29 | Copy Constructible 30 | 31 | 32 |

Notation

33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
PMapA type that is a model of Writable Property Map.
pmapAn object of type PMap.
keyAn object of type boost::property_traits<PMap>::key_type.
valAn object of type boost::property_traits<PMap>::value_type.
52 | 53 |

Associated Types

54 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 64 | 65 | 66 | 67 | 68 | 73 | 74 | 75 | 76 | 77 | 78 | 82 | 83 | 84 |
Value Typeboost::property_traits<PMap>::value_type 61 | The type of the property. 62 |
Key Typeboost::property_traits<PMap>::key_type 69 | The type of the key object used to look up the property. The property 70 | map may be templated on the key type, in which case this typedef 71 | can be void. 72 |
Property Map Category boost::property_traits<PMap>::category 79 | The category of the property: a type convertible to 80 | writable_property_map_tag. 81 |
85 | 86 | 87 |

Valid Expressions

88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 101 | 102 | 103 |
NameExpressionReturn TypeDescription
Put Property Value[1]put(pmap, key, val)void 99 | Assign val to the property associated with k. 100 |
104 | 105 | 106 |

Notes

107 | 108 | [1] The function put() was originally named 109 | set(), but was changed to avoid name conflicts with the 110 | std::set class when using a compiler (Microsoft Visual C++) 111 | with non-standard name lookup rules. The following example demonstrates 112 | the problem. 113 |
#include <set>
114 | using namespace std;
115 | namespace boost {
116 |   void set() { }
117 | }
118 | 119 | 120 |

Concept Checking Class

121 | 122 |
  template <class PMap, class Key>
123 |   struct WritablePropertyMapConcept
124 |   {
125 |     typedef typename property_traits<PMap>::key_type key_type;
126 |     typedef typename property_traits<PMap>::category Category;
127 |     typedef boost::writable_property_map_tag WritableTag;
128 |     void constraints() {
129 |       function_requires< ConvertibleConcept<Category, WritableTag> >();
130 |       put(pmap, k, val);
131 |     }
132 |     PMap pmap;
133 |     Key k;
134 |     typename property_traits<PMap>::value_type val;
135 |   };
136 | 137 |

See Also

138 | 139 | Property map concepts 140 | 141 | 142 |
143 |
144 | 145 | 146 |
Copyright © 2000 147 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) 148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /doc/associative_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Associative Property Map Adaptor 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | associative_property_map<UniquePairAssociativeContainer>
 23 | 
24 | 25 |

26 | This property map is an adaptor that converts any type that is a model 27 | of both Pair 29 | Associative Container and Unique 31 | Associative Container such as std::map into 33 | a mutable Lvalue Property Map. 34 | Note that the adaptor only retains a reference to the container, so 35 | the lifetime of the container must encompass the use of the adaptor. 36 |

37 | 38 |

Example

39 | 40 | example1.cpp: 41 |
#include <iostream>
 42 | #include <map>
 43 | #include <string>
 44 | #include <boost/property_map/property_map.hpp>
 45 | 
 46 | 
 47 | template <typename AddressMap>
 48 | void foo(AddressMap address)
 49 | {
 50 |   typedef typename boost::property_traits<AddressMap>::value_type value_type;
 51 |   typedef typename boost::property_traits<AddressMap>::key_type key_type;
 52 | 
 53 |   value_type old_address, new_address;
 54 |   key_type fred = "Fred";
 55 |   old_address = get(address, fred);
 56 |   new_address = "384 Fitzpatrick Street";
 57 |   put(address, fred, new_address);
 58 | 
 59 |   key_type joe = "Joe";
 60 |   value_type& joes_address = address[joe];
 61 |   joes_address = "325 Cushing Avenue";
 62 | }
 63 | 
 64 | int
 65 | main()
 66 | {
 67 |   std::map<std::string, std::string> name2address;
 68 |   boost::associative_property_map< std::map<std::string, std::string> >
 69 |     address_map(name2address);
 70 | 
 71 |   name2address.insert(make_pair(std::string("Fred"), 
 72 | 				std::string("710 West 13th Street")));
 73 |   name2address.insert(make_pair(std::string("Joe"), 
 74 | 				std::string("710 West 13th Street")));
 75 | 
 76 |   foo(address_map);
 77 |   
 78 |   for (std::map<std::string, std::string>::iterator i = name2address.begin();
 79 |        i != name2address.end(); ++i)
 80 |     std::cout << i->first << ": " << i->second << "\n";
 81 | 
 82 |   return EXIT_SUCCESS;
 83 | }
84 | 85 |

Where Defined

86 | 87 |

88 | boost/property_map/property_map.hpp 89 | 90 |

91 |

Model Of

92 | 93 | Lvalue Property Map 94 | 95 |

96 | 97 |

Template Parameters

98 | 99 |

100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 114 | 115 | 116 | 117 |
ParameterDescriptionDefault
UniquePairAssociativeContainerMust be a model of both Pair 111 | Associative Container and Unique 113 | Associative Container . 
118 |

119 | 120 |

Members

121 | 122 |

123 | In addition to the methods and functions required by Lvalue Property Map, this 125 | class has the following members. 126 | 127 |


128 | 129 |
130 | property_traits<associative_property_map>::value_type
131 | 
132 | This is the same type as 133 | UniquePairAssociativeContainer::data_type. 134 | 135 |
136 | 137 |
138 | associative_property_map()
139 | 
140 | Default Constructor. 141 | 142 |
143 | associative_property_map(UniquePairAssociativeContainer& c)
144 | 
145 | Constructor. 146 | 147 |
148 | 149 |
150 | data_type& operator[](const key_type& k) const
151 | 
152 | The operator bracket for property access. 153 | The key_type and 154 | data_type types are from the typedefs inside of 155 | UniquePairAssociativeContainer. 156 | 157 |
158 | 159 |

Non-Member functions

160 | 161 |
162 | 163 |
164 |   template <typename UniquePairAssociativeContainer>
165 |   associative_property_map<UniquePairAssociativeContainer>
166 |   make_assoc_property_map(UniquePairAssociativeContainer& c);
167 | 
168 | A function for conveniently creating an associative property map. 169 | 170 | 171 | 172 |
173 | 174 | 175 |
176 |
177 | 178 | 179 |
Copyright © 2002 180 | Jeremy Siek, 181 | Indiana University (jsiek@osl.iu.edu)
183 | Lie-Quan Lee, Indiana University (llee1@osl.iu.edu)
184 | Andrew Lumsdaine, 185 | Indiana University (lums@osl.iu.edu) 187 |
188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /doc/compose_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | Compose Property Map Adaptor 13 | 14 | 15 | 17 | C++ Boost 19 | 20 |
21 | 22 | 23 |

24 | Compose Property Map 25 | Adaptor 26 |

27 | 28 |
 29 | compose_property_map<FPMap, GPMap>
 30 | 
31 | 32 |

33 | This property map is an adaptor that composes two property map. The 34 | new property map will of the same model 35 | as FPMap. GPMap must 36 | model Readable Property Map. 37 |

38 | 39 |

Example

40 | 41 | compose_property_map_example.cpp: 42 |
 43 | #include <boost/property_map/compose_property_map.hpp>
 44 | #include <iostream>
 45 | 
 46 | int main()
 47 | {
 48 |     const int idx[] = {2, 0, 4, 1, 3};
 49 |     double v[] = {1., 3., 0., 4., 2.};
 50 |     boost::compose_property_map<double*, const int*> cpm(v, idx);
 51 | 
 52 |     for (int i = 0; i < 5; ++i)
 53 |         std::cout << get(cpm, i) << " ";
 54 |     std::cout << std::endl;
 55 | 
 56 |     for (int i = 0; i < 5; ++i)
 57 |         ++cpm[i];
 58 | 
 59 |     for (int i = 0; i < 5; ++i)
 60 |         std::cout << get(cpm, i) << " ";
 61 |     std::cout << std::endl;
 62 | 
 63 |     for (int i = 0; i < 5; ++i)
 64 |         put(cpm, i, 42.);
 65 | 
 66 |     for (int i = 0; i < 5; ++i)
 67 |         std::cout << get(cpm, i) << " ";
 68 |     std::cout << std::endl;
 69 | 
 70 |     return 0;
 71 | }
 72 | 
73 | 74 |

Output:

75 |
 76 | 0 1 2 3 4 
 77 | 1 2 3 4 5 
 78 | 42 42 42 42 42 
 79 | 
80 | 81 |

Where Defined

82 | 83 |

84 | boost/property_map/compose_property_map.hpp 85 |

86 | 87 |

Template Parameters

88 | 89 |

90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |
ParameterDescription
FPMapMust be a property map of any kind.
GPMapMust be a model of Readable Property Map.
108 | 109 |

Members

110 | 111 |

112 | In addition to the methods and functions required by property maps, 113 | this class has the following members: 114 |

115 | 116 |
117 | 118 |
119 | compose_property_map(const FPMap& f, const GPMap& g);
120 | 
121 | Constructor. 122 | 123 |
124 | 125 |

Non-Member functions

126 | 127 |
128 | 129 |
130 |   template <class FPMap, class GPMap>
131 |   compose_property_map<FPMap, GPMap>
132 |   make_compose_property_map(const FPMap& f, const GPMap& g);
133 | 
134 | Returns a compose_property_map using the given property maps type. 135 | 136 |
137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 |
Copyright © 2013Eurodecision
Author:Guillaume Pinot
148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /doc/const_assoc_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Constant Associative Property Map Adaptor 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | const_associative_property_map<UniquePairAssociativeContainer>
 23 | 
24 | 25 |

26 | This property map is an adaptor that converts any type that is a model 27 | of both Pair 29 | Associative Container and Unique 31 | Associative Container such as std::map into 33 | a constant Lvalue Property Map. 34 | Note that the adaptor only retains a reference to the container, so 35 | the lifetime of the container must encompass the use of the adaptor. 36 |

37 | 38 |

Example

39 | 40 | example1.cpp: 41 |
 42 | #include <iostream>
 43 | #include <map>
 44 | #include <string>
 45 | #include <boost/property_map/property_map.hpp>
 46 | 
 47 | 
 48 | template <typename ConstAddressMap>
 49 | void display(ConstAddressMap address)
 50 | {
 51 |   typedef typename boost::property_traits<ConstAddressMap>::value_type
 52 |     value_type;
 53 |   typedef typename boost::property_traits<ConstAddressMap>::key_type key_type;
 54 | 
 55 |   key_type fred = "Fred";
 56 |   key_type joe = "Joe";
 57 | 
 58 |   value_type freds_address = get(address, fred);
 59 |   value_type joes_address = get(address, joe);
 60 |   
 61 |   std::cout << fred << ": " << freds_address << "\n"
 62 | 	    << joe  << ": " << joes_address  << "\n";
 63 | }
 64 | 
 65 | int
 66 | main()
 67 | {
 68 |   std::map<std::string, std::string> name2address;
 69 |   boost::const_associative_property_map< std::map<std::string, std::string> >
 70 |     address_map(name2address);
 71 | 
 72 |   name2address.insert(make_pair(std::string("Fred"), 
 73 | 				std::string("710 West 13th Street")));
 74 |   name2address.insert(make_pair(std::string("Joe"), 
 75 | 				std::string("710 West 13th Street")));
 76 | 
 77 |   display(address_map);
 78 |   
 79 |   return EXIT_SUCCESS;
 80 | }
 81 | 
 82 | 
 83 | 
84 | 85 |

Where Defined

86 | 87 |

88 | boost/property_map/property_map.hpp 89 | 90 |

91 |

Model Of

92 | 93 | Lvalue Property Map 94 | 95 |

96 | 97 |

Template Parameters

98 | 99 |

100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 114 | 115 | 116 | 117 |
ParameterDescriptionDefault
UniquePairAssociativeContainerMust be a model of both Pair 111 | Associative Container and Unique 113 | Associative Container . 
118 |

119 | 120 |

Members

121 | 122 |

123 | In addition to the methods and functions required by Lvalue Property Map, this 125 | class has the following members. 126 | 127 |


128 | 129 |
130 | property_traits<const_associative_property_map>::value_type
131 | 
132 | This is the same type as 133 | UniquePairAssociativeContainer::data_type. 134 | 135 |
136 | 137 |
138 | const_associative_property_map()
139 | 
140 | Default Constructor. 141 | 142 |
143 | const_associative_property_map(const UniquePairAssociativeContainer& c)
144 | 
145 | Constructor. 146 | 147 |
148 | 149 |
150 | const data_type& operator[](const key_type& k) const
151 | 
152 | The operator bracket for property access. 153 | The key_type and 154 | data_type types are from the typedefs inside of 155 | UniquePairAssociativeContainer. 156 | 157 |
158 | 159 |

Non-Member functions

160 | 161 |
162 | 163 |
164 |   template <typename UniquePairAssociativeContainer>
165 |   const_associative_property_map<UniquePairAssociativeContainer>
166 |   make_assoc_property_map(const UniquePairAssociativeContainer& c);
167 | 
168 | A function for conveniently creating an associative property map. 169 | 170 | 171 | 172 |
173 | 174 | 175 |
176 |
177 | 178 | 179 |
Copyright © 2002 180 | Jeremy Siek, 181 | Indiana University (jsiek@osl.iu.edu)
183 | Lie-Quan Lee, Indiana University (llee1@osl.iu.edu)
184 | Andrew Lumsdaine, 185 | Indiana University (lums@osl.iu.edu) 187 |
188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /doc/dynamic_property_map.rst: -------------------------------------------------------------------------------- 1 | ================================ 2 | |(logo)|__ Dynamic Property Maps 3 | ================================ 4 | 5 | .. Copyright 2004-5 The Trustees of Indiana University. 6 | 7 | Use, modification and distribution is subject to the Boost Software 8 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | .. |(logo)| image:: ../../../boost.png 12 | :align: middle 13 | :alt: Boost 14 | 15 | __ ../../../index.htm 16 | 17 | Summary 18 | ------- 19 | The dynamic property map interfaces provides access to a collection of 20 | property maps through a dynamically-typed interface. An algorithm can 21 | use it to manipulate property maps without knowing their key or 22 | value types at compile-time. Type-safe codes can use dynamic property 23 | maps to interface more easily and completely with scripting languages 24 | and other text-based representations of key-value data. 25 | 26 | .. contents:: 27 | 28 | Introduction 29 | ------------ 30 | The Boost Property Map library specifies statically type-safe 31 | interfaces through which key-value pairs can be manipulated by 32 | generic algorithms. Typically, an algorithm that uses property maps is 33 | parameterized on the types of the property maps it uses, and it 34 | manipulates them using the interfaces specified by the 35 | Boost Property Map Library. 36 | 37 | The following generic function illustrates property map basics. 38 | 39 | 40 | :: 41 | 42 | template 43 | void 44 | manipulate_freds_info(AgeMap ages, GPAMap gpas) { 45 | 46 | typedef typename boost::property_traits::key_type name_type; 47 | typedef typename boost::property_traits::value_type age_type; 48 | typedef typename boost::property_traits::value_type gpa_type; 49 | 50 | name_type fred = "Fred"; 51 | 52 | age_type old_age = get(ages, fred); 53 | gpa_type old_gpa = get(gpas, fred); 54 | 55 | std::cout << "Fred's old age: " << old_age << "\n" 56 | << "Fred's old gpa: " << old_gpa << "\n"; 57 | 58 | age_type new_age = 18; 59 | gpa_type new_gpa = 3.9; 60 | put(ages, fred, new_age); 61 | put(gpas, fred, new_gpa); 62 | } 63 | 64 | The function is parameterized on two property map types, ``AgeMap`` and 65 | ``GPAMap``, and takes a value parameter for each of those types. The 66 | function uses the ``property_traits`` interface to ascertain, at 67 | compile-time, the value and key types of the property maps. The code 68 | then retrieves Fred's old information, using the ``get`` function, and 69 | updates it using the ``put`` function. The ``get`` function is required by the 70 | Readable Property Map concept and both ``get`` and ``put`` are required by the 71 | Read/Write Property Map concept. 72 | 73 | The above function not only requires the two type parameters to model 74 | property map concepts, but also makes some extra assumptions. 75 | ``AgeMap`` and ``GPAMap`` must have the same key type, and that type must be 76 | constructable from a string. Furthermore, ``AgeMap``'s value type must be 77 | constructable from an ``int``. Although these requirements are not 78 | explicitly stated, they are statically checked during compilation and 79 | failure to meet them yields compile-time errors. 80 | 81 | Although the static typing of property map interfaces usually provides 82 | desirable compile-time safety, some algorithms require a more dynamic 83 | interface to property maps. For example, the Boost Graph Library (BGL) 84 | provides functions that can initialize a graph by interpreting the 85 | contents of a textual graph description (i.e. a GraphML file). Such 86 | general-purpose graph description languages can specify an arbitrary 87 | number of edge and vertex properties, using strings to represent the 88 | key-value pairs. A graph reader function should capture these 89 | arbitrary properties, but since function templates can only be 90 | parameterized on a fixed number of property maps, the traditional 91 | techniques for handling property maps do not suffice to implement them. 92 | 93 | Dynamic property maps specifically address the need for an interface 94 | to property maps whose checking is delayed to runtime. Several 95 | components combine to provide support for dynamic property maps. The 96 | ``dynamic_properties`` class collects a 97 | group of heterogenous objects that model concepts from 98 | the Boost Property Map library. Each property map is assigned a 99 | string-based key when it is added to the collection, and it can be 100 | addressed using that key. Internally, ``dynamic_properties`` adapts 101 | each contained property map with the dynamic property map interface, 102 | which provides ``get`` and ``put`` functions that 103 | can be called using values of any type that meets a few requirements. 104 | Internally, the dynamic property map converts key and value pairs to 105 | meet the requirements of the underlying property map or signals a 106 | runtime exception if it cannot. 107 | 108 | 109 | "Fred's Info" Revisited 110 | ~~~~~~~~~~~~~~~~~~~~~~~ 111 | Here's what the example above looks like using the 112 | ``dynamic_properties`` interface: 113 | 114 | :: 115 | 116 | void manipulate_freds_info(boost::dynamic_properties& properties) 117 | { 118 | using boost::get; 119 | std::string fred = "Fred"; 120 | 121 | int old_age = get("age", properties, fred); 122 | std::string old_gpa = get("gpa", properties, fred); 123 | 124 | std::cout << "Fred's old age: " << old_age << "\n" 125 | << "Fred's old gpa: " << old_gpa << "\n"; 126 | 127 | std::string new_age = "18"; 128 | double new_gpa = 3.9; 129 | put("age",properties,fred,new_age); 130 | put("gpa",properties,fred,new_gpa); 131 | } 132 | 133 | The new function is not a template parameterized on the property map 134 | types but instead a concrete function that takes a ``dynamic_properties`` 135 | object. Furthermore, the code no longer makes reference to key or 136 | value types: keys and values are represented with strings. 137 | Nonetheless the function still uses non-string types where they are 138 | useful. For instance, Fred's old age is represented using an ``int``. 139 | It's value is retreived by calling ``get`` with a 140 | type parameter, which determines its return type. Finally, the 141 | ``get`` and ``put`` functions are each supplied a string-based key that 142 | differs depending on the property of concern. 143 | 144 | Here's an example of how the above function might be called. 145 | 146 | :: 147 | 148 | int main() 149 | { 150 | using boost::get; 151 | 152 | // build property maps using associative_property_map 153 | std::map name2age; 154 | std::map name2gpa; 155 | boost::associative_property_map< std::map > 156 | age_map(name2age); 157 | boost::associative_property_map< std::map > 158 | gpa_map(name2gpa); 159 | 160 | std::string fred("Fred"); 161 | // add key-value information 162 | name2age.insert(make_pair(fred,17)); 163 | name2gpa.insert(make_pair(fred,2.7)); 164 | 165 | // build and populate dynamic interface 166 | boost::dynamic_properties properties; 167 | properties.property("age",age_map); 168 | properties.property("gpa",gpa_map); 169 | 170 | manipulate_freds_info(properties); 171 | 172 | std::cout << "Fred's age: " << get(age_map,fred) << "\n" 173 | << "Fred's gpa: " << get(gpa_map,fred) << "\n"; 174 | } 175 | 176 | The code first creates two property maps using ``std::map`` and the 177 | ``associative_property_map`` adaptor. After initializing the 178 | property maps with key-value data, it constructs a 179 | ``dynamic_properties`` object and adds to it both property maps, 180 | keyed on the strings "age" and "gpa". Finally ``manipulate_freds_info`` 181 | is passed the ``dynamic_properties`` object and the results of its changes are 182 | displayed. 183 | 184 | As shown above, the ``dynamic_properties`` object provides, where needed, a 185 | dynamically-typed interface to property maps yet preserves the static 186 | typing of property map uses elsewhere in an application. 187 | 188 | Reference 189 | --------- 190 | :: 191 | 192 | class dynamic_properties 193 | 194 | The ``dynamic_properties`` class provides a dynamically-typed interface to 195 | a set of property maps. To use it, one must populate 196 | an object of this class with property maps using the ``property`` member 197 | function. 198 | 199 | Member Functions 200 | ~~~~~~~~~~~~~~~~ 201 | 202 | :: 203 | 204 | dynamic_properties() 205 | dynamic_properties( 206 | const boost::function< 207 | boost::shared_ptr ( 208 | const std::string&, const boost::any&, const boost::any&) 209 | >& fn) 210 | 211 | A ``dynamic_properties`` object can be constructed with a function object 212 | that, when called, creates a new property map. The library provides the 213 | ``ignore_other_properties`` function object, which lets the ``dynamic_properties`` object ignore any properties that it hasn't been prepared to record. 214 | If an attempt is made 215 | to ``put`` a key-value pair to a nonexistent ``dynamic_properties`` key, 216 | then this function is called with the ``dynamic_properties`` key and the 217 | intended property key and value . If ``dynamic_properties`` is 218 | default-constructed, such a ``put`` attempt throws 219 | ``property_not_found``. 220 | 221 | 222 | :: 223 | 224 | template 225 | dynamic_properties& 226 | property(const std::string& name, PropertyMap property_map) 227 | 228 | This member function adds a property map to the set of maps contained, 229 | using ``name`` as its key. 230 | 231 | Requirements: ``PropertyMap`` must model Readable Property Map or 232 | Read/Write Property Map. 233 | 234 | :: 235 | 236 | void insert(const std::string& name, boost::shared_ptr pm) 237 | 238 | This member function directly adds a ``dynamic_property_map`` 239 | to the collection, using ``name`` as its key. 240 | 241 | :: 242 | 243 | iterator begin() 244 | const_iterator begin() const 245 | 246 | This member function returns an iterator over the set of property maps 247 | held by the ``dynamic_properties`` object. 248 | 249 | :: 250 | 251 | iterator end() 252 | const_iterator end() const 253 | 254 | This member function returns a terminal iterator over the set of 255 | dynamic property maps held by the ``dynamic_properties`` object. It is used to 256 | terminate traversals over the set of dynamic property maps 257 | 258 | :: 259 | 260 | iterator lower_bound(const std::string& name) 261 | 262 | This member function returns an iterator that points to the first 263 | property map whose ``dynamic_properties`` key is ``name``. 264 | Bear in mind that multiple property maps may have the same 265 | ``dynamic_properties`` key, so long as their property map key types differ. 266 | 267 | Invariant: The range [ lower_bound(name), end() ) contains every 268 | property map that has name for its ``dynamic_properties`` key. 269 | 270 | Free functions 271 | ~~~~~~~~~~~~~~ 272 | 273 | :: 274 | 275 | boost::shared_ptr 276 | ignore_other_properties(const std::string&, 277 | const boost::any&, 278 | const boost::any&) 279 | 280 | When passed to the ``dynamic_properties`` constructor, this function 281 | allows the ``dynamic_properties`` object to disregard attempts to put 282 | values to unknown keys without signaling an error. 283 | 284 | :: 285 | 286 | template 287 | bool put(const std::string& name, dynamic_properties& dp, const Key& key, 288 | const Value& value) 289 | 290 | This function adds a key-value pair to the property map with the 291 | matching name and key type. If no matching property map is found, 292 | behavior depends on the availability of a property map generator. If 293 | a property map generator was supplied when the ``dynamic_properties`` 294 | object was constructed, then that function is used to create a new 295 | property map. If the generator fails to generate a property map 296 | (returns a null ``shared_ptr``), then the ``put`` function returns 297 | ``false``. If, on the other hand, the ``dynamic_properties`` object 298 | has no property map generator (meaning it was default-constructed), 299 | then ``property_not_found`` is thrown. If a candidate property map is 300 | found but it does not support ``put``, ``dynamic_const_put_error`` is 301 | thrown. 302 | 303 | :: 304 | 305 | template 306 | Value get(const std::string& name, const dynamic_properties& dp, 307 | const Key& key) 308 | 309 | This function gets the value from the property-map whose namee is 310 | given and whose key type matches. If ``Value`` is ``std::string``, then the 311 | property map's value type must either be ``std::string`` or model 312 | OutputStreamable. In the latter case, the ``get`` function converts the 313 | value to a string. If no matching property map is found, 314 | ``dynamic_get_failure`` is thrown. 315 | 316 | 317 | ============================================================================= 318 | 319 | :: 320 | 321 | class dynamic_property_map 322 | 323 | This class describes the interface used by ``dynamic_properties`` to 324 | interact with a user's property maps polymorphically. 325 | 326 | :: 327 | 328 | boost::any get(const any& key) 329 | 330 | Given a representation of a key, return the value associated with that key. 331 | 332 | Requirement: 333 | 1) The object passed as the key must be convertible to a value of the 334 | map's key type. Details of that conversion are unspecified. 335 | 2) For this expression to be valid, the key must be 336 | associated with some value, otherwise the result is undefined. 337 | 338 | :: 339 | 340 | std::string get_string(const any& key) 341 | 342 | Given a representation of a key, return the string representation 343 | of the value associated with that key. 344 | 345 | Requirements: 346 | 1) The object passed as the key must be convertible to the 347 | property map's key type. Details of that conversion are unspecified. 348 | 2) For this expression to be valid, the key must be 349 | associated with some value, otherwise the result is undefined. 350 | 3) The value type of the property map must model Output Streamable. 351 | 352 | :: 353 | 354 | void put(const any& key, const any& value) 355 | 356 | Given a representation of a key and a representation of a value, the 357 | key and value are associated in the property map. 358 | 359 | Requirements: 360 | 1) The object passed as the key must be convertible to the 361 | property map's key type. Details of that conversion are unspecified. 362 | 2) The object passed as the value must be convertible to the 363 | property map's value type. Details of that conversion are unspecified. 364 | 3) The property map need not support this member function, in which 365 | case an error will be signaled. This is the runtime analogue of the 366 | Readable Property Map concept. 367 | 368 | :: 369 | 370 | const std::type_info& key() const 371 | 372 | Returns a ``type_info`` object that represents the property map's key type. 373 | 374 | :: 375 | 376 | const std::type_info& value() const 377 | 378 | Returns a ``type_info`` object that represents the property map's value type. 379 | 380 | 381 | Exceptions 382 | ~~~~~~~~~~ 383 | 384 | :: 385 | 386 | struct dynamic_property_exception : public std::exception { 387 | virtual ~dynamic_property_exception() throw() {} 388 | }; 389 | 390 | struct property_not_found : public std::exception { 391 | std::string property; 392 | property_not_found(const std::string& property); 393 | virtual ~property_not_found() throw(); 394 | 395 | const char* what() const throw(); 396 | }; 397 | 398 | struct dynamic_get_failure : public std::exception { 399 | std::string property; 400 | dynamic_get_failure(const std::string& property); 401 | virtual ~dynamic_get_failure() throw(); 402 | 403 | const char* what() const throw(); 404 | }; 405 | 406 | struct dynamic_const_put_error : public std::exception { 407 | virtual ~dynamic_const_put_error() throw(); 408 | 409 | const char* what() const throw(); 410 | }; 411 | 412 | 413 | Under certain circumstances, calls to ``dynamic_properties`` member 414 | functions will throw one of the above exceptions. The three concrete 415 | exceptions can all be caught using the general 416 | ``dynamic_property_exception`` moniker when greater precision is not 417 | needed. In addition, all of the above exceptions derive from the 418 | standard ``std::exception`` for even more generalized error handling. 419 | The specific circumstances that result in these exceptions are 420 | described above. 421 | -------------------------------------------------------------------------------- /doc/function_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Function Property Map Adaptor 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | function_property_map<UnaryFunction, Key, Ref>
 23 | 
24 | 25 |

26 | This property map is an adaptor that converts a function object into either a Readable Property Map or a Lvalue Property Map. The category of the property map is based on whether the function's return type (as given by Ref) is a non-const reference type. 27 | 28 |

29 | 30 | 34 | 35 |

Where Defined

36 | 37 |

38 | boost/property_map/function_property_map.hpp 39 | 40 |

41 |

Model Of

42 | 43 | Readable Property Map or Lvalue Property Map 44 | 45 |

46 | 47 |

Template Parameters

48 | 49 |

50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
ParameterDescriptionDefault
UnaryFunctionMust be a model of Unary Function that accepts an object of type Key as an argument and returns a result of type Ref. 
Key The key type of the property map. 65 |  
RefThe result type of the function.boost::result_of<const UnaryFunction(const Key&)>::type
76 |

77 | 78 |

Members

79 | 80 |

81 | In addition to the methods and functions required by Readable Property Map or Lvalue Property Map, this 83 | class has the following members: 84 | 85 |


86 | 87 |
 88 | property_traits<function_property_map>::value_type
 89 | 
90 | The type Ref with any reference or cv-qualifiers removed. 91 | 92 |
93 | 94 |
 95 | function_property_map(const UnaryFunction& f = UnaryFunction())
 96 | 
97 | Constructor. 98 | 99 |
100 | 101 |

Non-Member functions

102 | 103 |
104 | 105 |
106 |   template <class Key, class UnaryFunction>
107 |   function_property_map<UnaryFunction, Key>
108 |   make_function_property_map(const UnaryFunction& f);
109 | 
110 | Returns a function_property_map using the given function and key type. 111 | 112 |
113 | 114 |
115 |   template <class Key, class Ref, class UnaryFunction>
116 |   function_property_map<UnaryFunction, Key, Ref>
117 |   make_function_property_map(const UnaryFunction& f);
118 | 
119 | Returns a function_property_map using the given function and key and reference types. 120 | 121 |
122 | 123 |
124 |
125 | 126 | 127 |
Copyright © 2012Trustees of Indiana University 128 |
129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /doc/identity_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Identity Property Map 11 | 13 | C++ Boost 15 | 16 |
17 | 18 |

19 | 20 |
 21 | boost::typed_identity_property_map<T>
 22 | 
 23 | typedef boost::typed_identity_propoperty_map<std::size_t> boost::identity_property_map
 24 | 
25 | 26 |

The typed_identity_property_map property map applies the identity function, that is, it just returns a copy of the key object that was input. The key and value types are both the same as the template parameter T. The identity_property_map name is for the common case where the key and value type are std::size_t (this name is deprecated for use within Boost.Graph).

27 |

Note: Previously the function get() and operator[] for identity_property_map were overloaded to return a copy of keys of any type, i.e., not just size_t. These overloads are now deprecated, because they did not adhere to the property map concepts.

28 | 29 |

Where Defined

30 | 31 |

32 | boost/property_map/property_map.hpp 33 |

34 | 35 |

Model of

36 | 37 | Readable Property Map 38 | 39 |

Template Parameters

40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
ParameterDescriptionDefault
TMust be Copy Contructible 
52 |

Associated Types

53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 65 | 66 | 67 | 68 | 71 | 73 | 74 | 75 | 76 | 79 | 81 | 82 | 83 | 84 | 87 | 90 | 91 | 92 |
TypeDescription
61 | boost::property_traits<typed_identity_property_map<T> >::value_type 62 | 64 | This type is T.
69 | boost::property_traits<typed_identity_property_map<T> >::key_type 70 | 72 | This type is T.
77 | boost::property_traits<typed_identity_property_map<T> >::reference 78 | 80 | This type is T..
85 | boost::property_traits<typed_identity_property_map<T> >::category 86 | 88 | This type is boost::readable_property_map_tag. 89 |
93 | 94 |

Member Functions

95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 109 | 110 | 111 | 112 | 115 | 118 | 119 | 120 | 121 | 124 | 127 | 128 | 129 |
MemberDescription
104 | typed_identity_property_map() 105 | 107 | Default constructor. 108 |
113 | typed_identity_property_map(const typed_identity_property_map<T>& x) 114 | 116 | Copy constructor. 117 |
122 | T operator[](const T& x) const 123 | 125 | Returns a copy of object x. 126 |
130 | 131 |

Non-Member Functions

132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 141 | 144 | 145 | 146 |
MemberDescription
T get(const typed_identity_property_map<T>& pmap, const T& x) 140 | 142 | Returns a copy of object x. 143 |
147 | 148 | 149 |
150 |
151 | 152 | 153 |
Copyright © 2000-2012 154 | Jeremy Siek, 155 | Univ.of Notre Dame (jsiek@lsc.nd.edu)
157 | Lie-Quan Lee, Univ. of Notre Dame (llee1@lsc.nd.edu)
158 | Andrew Lumsdaine, 159 | Univ.of Notre Dame (lums@lsc.nd.edu)
161 | Alex Hagen-Zanker
162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /doc/iterator_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Iterator Property Map Adaptor 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | iterator_property_map<RandomAccessIterator, OffsetMap, T, R>
 23 | 
24 | 25 |

26 | This property map is an adaptor that converts any random access 27 | iterator into a Lvalue Property Map. 29 | The OffsetMap type is responsible for converting 30 | key objects to integers that can be used as offsets with the 31 | random access iterator. 32 | 33 |

34 | 35 |

Example

36 | 37 |
 38 | // print out the capacity and flow for all the edges in the graph
 39 | template <class Graph, class CapacityPMap, class FlowPMap>
 40 | void print_network(Graph& G, CapacityPMap capacity, FlowPMap flow)
 41 | {
 42 |   typedef typename boost::graph_traits<Graph>::vertex_iterator    Viter;
 43 |   typedef typename boost::graph_traits<Graph>::out_edge_iterator OutEdgeIter;
 44 |   typedef typename boost::graph_traits<Graph>::in_edge_iterator InEdgeIter;
 45 | 
 46 |   Viter ui, uiend;
 47 |   for (boost::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) {
 48 |     OutEdgeIter out, out_end;
 49 |     std::cout << *ui << "\t";
 50 | 
 51 |     for(boost::tie(out, out_end) = out_edges(*ui, G); out != out_end; ++out)
 52 |       std::cout << "--(" << get(capacity, *out) << ", " 
 53 | 	   << get(flow, *out) << ")--> " << target(*out,G) << "\t";
 54 |     std::cout << std::endl << "\t";
 55 | 
 56 |     InEdgeIter in, in_end;    
 57 |     for(boost::tie(in, in_end) = in_edges(*ui, G); in != in_end; ++in)
 58 |       std::cout << "<--(" << get(capacity, *in) << "," << get(flow, *in) << ")-- "
 59 |            << source(*in,G) << "\t";
 60 |     std::cout << std::endl;
 61 |   }
 62 | }
 63 | 
 64 | int main(int, char*[])
 65 | {
 66 |   typedef boost::adjacency_list<boost::vecS, boost::vecS, 
 67 |     boost::bidirectionalS, boost::no_plugin, 
 68 |     boost::plugin<boost::id_tag, std::size_t> > Graph;
 69 | 
 70 |   const int num_vertices = 9;
 71 |   Graph G(num_vertices);
 72 | 
 73 |   int capacity[] = { 10, 20, 20, 20, 40, 40, 20, 20, 20, 10 };
 74 |   int flow[] = { 8, 12, 12, 12, 12, 12, 16, 16, 16, 8 };
 75 | 
 76 |   // add edges to the graph, and assign each edge an ID number
 77 |   // to index into the property arrays
 78 |   add_edge(G, 0, 1, 0);
 79 |   // ...
 80 | 
 81 |   typedef boost::graph_traits<Graph>::edge_descriptor Edge;
 82 |   typedef boost::property_map<Graph, boost::id_tag>::type EdgeID_PMap;
 83 |   EdgeID_PMap edge_id = get(boost::edge_index(), G);
 84 | 
 85 |   boost::iterator_property_map<int*, EdgeID_PMap, int, int&>
 86 |      capacity_pa(capacity, edge_id),
 87 |      flow_pa(flow, edge_id);
 88 | 
 89 |   print_network(G, capacity_pa, flow_pa);
 90 |           
 91 |   return 0;
 92 | }
 93 | 
94 | 95 |

Where Defined

96 | 97 |

98 | boost/property_map/property_map.hpp 99 | 100 |

101 |

Model Of

102 | 103 | Lvalue Property Map 104 | 105 |

106 | 107 |

Template Parameters

108 | 109 |

110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
ParameterDescriptionDefault
IteratorMust be a model of Random Access Iterator. 
OffsetMap Must be a model of Readable Property Map 126 | and the value type must be convertible to the difference type of the 127 | iterator.  
TThe value type of the iterator.std::iterator_traits<RandomAccessIterator>::value_type
RThe reference type of the iterator.std::iterator_traits<RandomAccessIterator>::reference
144 |

145 | 146 |

Members

147 | 148 |

149 | In addition to the methods and functions required by Lvalue Property Map, this 151 | class has the following members. 152 | 153 |


154 | 155 |
156 | property_traits<iterator_property_map>::value_type
157 | 
158 | This is the same type as 159 | std::iterator_traits<Iterator>::value_type. 160 | 161 |
162 | 163 |
164 | iterator_property_map(Iterator i)
165 | 
166 | Constructor. The OffsetMap is default constructed. 167 | 168 |
169 | 170 |
171 | iterator_property_map(Iterator i, OffsetMap m)
172 | 
173 | Constructor. 174 | 175 |
176 | 177 |
178 | reference operator[](const key_type& v) const
179 | 
180 | The operator bracket for property access. The reference is from 181 | std::iterator_traits<Iterator> and the key_type is from boost::property_traits<OffsetMap>. 182 |
183 | 184 |

Non-Member functions

185 | 186 |
187 | 188 |
189 |   template <class RAIter, class OffsetMap>
190 |   iterator_property_map<RAIter, OffsetMap,
191 |     typename std::iterator_traits<RAIter>::value_type,
192 |     typename std::iterator_traits<RAIter>::reference
193 |     >
194 |   make_iterator_property_map(RAIter iter, OffsetMap omap)
195 | 
196 | A function for conveniently creating an iterator map. 197 | 198 | 199 |
200 | 201 |
202 |   template <class RAIter, class OffsetMap, class ValueType>
203 |   iterator_property_map<RAIter, OffsetMap,
204 |     typename std::iterator_traits<RAIter>::value_type,
205 |     typename std::iterator_traits<RAIter>::reference
206 |     >
207 |   make_iterator_property_map(RAIter iter, OffsetMap omap, ValueType dummy_arg)
208 | 
209 | Use this function instead of the 2-argument version if 210 | your compiler does not support partial specialization 211 | (like Visual C++). 212 | 213 | 214 |
215 | 216 | 217 |
218 |
219 | 220 | 221 |
Copyright © 2000-2002 222 | Jeremy Siek, 223 | Univ.of Notre Dame (jsiek@osl.iu.edu)
225 | Lie-Quan Lee, Univ.of Notre Dame (llee1@osl.iu.edu)
226 | Andrew Lumsdaine, 227 | Univ.of Notre Dame (lums@osl.iu.edu) 229 |
230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /doc/property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Property Map Library 11 | 13 | C++ Boost 15 | 16 |
17 | 18 |

19 | Boost Property Map Library 20 |

21 | 22 |

The Boost Property Map Library consists mainly of interface 23 | specifications in the form of concepts (similar to the iterator 24 | concepts in the STL [2]). 26 | These interface specifications are intended for use by implementors of 27 | generic libraries in communicating requirements on template parameters 28 | to their users. In particular, the Boost Property Map concepts define 29 | a general purpose interface for mapping key objects to corresponding 30 | value objects, thereby hiding the details of how the mapping is 31 | implemented from algorithms. The implementation of types fulfilling 32 | the property map interface is up to the client of the algorithm to 33 | provide. The property map requirements are purposefully vague on the 34 | type of the key and value objects to allow for the utmost genericity 35 | in the function templates of the generic library. 36 |

37 | 38 |

39 | The need for the property map interface came from the Boost Graph Library (BGL), which 41 | contains many examples of algorithms that use the property map 42 | concepts to specify their interface. For an example, note the 43 | ColorMap template parameter of the 45 | breadth_first_search. In addition, the BGL contains many 46 | examples of concrete types that implement the property map interface. 47 | The 48 | adjacency_list class implements property maps for 49 | accessing objects (properties) that are attached to vertices and edges 50 | of the graph. 51 |

52 | 53 |

54 | The Boost Property Map Library also contains a few adaptors that convert commonly 56 | used data-structures that implement a mapping operation, such as 57 | builtin arrays (pointers), iterators, and std::map, to 59 | have the property map interface. These adaptors are not meant to 60 | fulfill all mapping needs, but are to serve as an example of how to 61 | implement the interface as well as covering a few common cases. See 62 | the header files for details. 63 |

64 | 65 |

Property maps are statically-typed entities. If you need to access 66 | property maps in a more dynamic setting (e.g., because you're reading 67 | an unknown set of attributes from a file), you can use the dynamic_properties 69 | class to access a set of property maps through a dynamically-typed 70 | interface.

71 | 72 |

73 | Property Map Concepts 74 |

75 | 76 | The property map interface consists of a set of concepts (see 77 | definition of "concept" in [1] and [2]) that 80 | define a syntax for mapping key objects to corresponding value 81 | objects. Since the property map operations are global functions 82 | (actually they don't have to be global, but they are always called 83 | unqualified and may be found via argument dependent lookup), it is 84 | possible to overload the map functions such that nearly arbitrary 85 | property map types and key types can be used. The interface for 86 | property maps consists of three functions: get(), 87 | put(), and operator[]. The following concrete 88 | example from example1.cpp shows how the 89 | three functions could be used to access the addresses associated with 90 | various people. We use a separate function template here to highlight 91 | the parts of the program that use the property map concept 92 | interface. In the main() function we use std::map 93 | and boost::associative_property_map, but it would have been 94 | OK to use any type (including a custom type that you create) that 95 | fulfills the property map requirements. 96 | 97 |
#include <iostream>
 98 | #include <map>
 99 | #include <string>
100 | #include <boost/property_map/property_map.hpp>
101 | 
102 | 
103 | template <typename AddressMap>
104 | void foo(AddressMap address)
105 | {
106 |   typedef typename boost::property_traits<AddressMap>::value_type value_type;
107 |   typedef typename boost::property_traits<AddressMap>::key_type key_type;
108 | 
109 |   value_type old_address, new_address;
110 |   key_type fred = "Fred";
111 |   old_address = get(address, fred);
112 |   new_address = "384 Fitzpatrick Street";
113 |   put(address, fred, new_address);
114 | 
115 |   key_type joe = "Joe";
116 |   value_type& joes_address = address[joe];
117 |   joes_address = "325 Cushing Avenue";
118 | }
119 | 
120 | int
121 | main()
122 | {
123 |   std::map<std::string, std::string> name2address;
124 |   boost::associative_property_map< std::map<std::string, std::string> >
125 |     address_map(name2address);
126 | 
127 |   name2address.insert(make_pair(std::string("Fred"), 
128 | 				std::string("710 West 13th Street")));
129 |   name2address.insert(make_pair(std::string("Joe"), 
130 | 				std::string("710 West 13th Street")));
131 | 
132 |   foo(address_map);
133 |   
134 |   for (std::map<std::string, std::string>::iterator i = name2address.begin();
135 |        i != name2address.end(); ++i)
136 |     std::cout << i->first << ": " << i->second << "\n";
137 | 
138 |   return EXIT_SUCCESS;
139 | }
140 | 141 |

142 | For each property map object there is a set of valid keys 143 | for which the mapping to value objects is defined. Invoking a 144 | property map function on an invalid key results in 145 | undefined behavior. The property map concepts do not specify how 146 | this set of valid keys is created or modified. A function that uses a 147 | property map must specify the expected set of valid keys in its 148 | preconditions. 149 | 150 |

151 | The need for property maps came out of the design of the Boost 152 | Graph Library, whose algorithms needed an interface for accessing 153 | properties attached to vertices and edges in a graph. In this context 154 | the vertex and edge descriptors are the key type of the property 155 | maps. 156 | 157 | 158 | 159 |

160 | Several categories of property maps provide 161 | different access capabilities: 162 |

163 |
readable
164 |
The associated property data can only be read. 165 | The data is returned by-value. Many property maps defining the 166 | problem input (such as edge weight) can be defined as readable 167 | property maps. 168 | 169 |

170 |

171 |
writeable
172 |
The associated property can only be written to. 173 | The parent array used to record the paths in a bread-first search tree 174 | is an example of a property map that would be defined writeable. 175 | 176 |

177 |

178 |
read/write
179 |
The associated property can both be written and read. 180 | The distance property use in Dijkstra's shortest paths algorithm 181 | would need to provide both read and write capabilities. 182 | 183 |

184 |

185 |
lvalue
186 |
The associated property is actually represented in 187 | memory and it is possible to get a reference to it. 188 | The property maps in the lvalue 189 | category also support the requirements for read/write property 190 | maps. 191 | 192 |

193 |

194 |
195 | 196 |

197 | There is a separate concept defined for each of the four property 198 | map categories. These property map concepts are listed 199 | below, with links to the documentation for each of them. 200 | 201 |

207 | 208 |

Property Map Category Tags

209 | 210 |

211 | There is a tag struct for each of the categories of property 212 | maps, which is defined in the header 213 | <boost/property_map/property_map.hpp>. 214 | 215 |

namespace boost {
216 | 
217 |   struct readable_property_map_tag { };
218 | 
219 |   struct writable_property_map_tag { };
220 | 
221 |   struct read_write_property_map_tag :
222 |     public readable_property_map_tag,
223 |     public writable_property_map_tag { };
224 | 
225 |   struct lvalue_property_map_tag : 
226 |     public read_write_property_map_tag { };
227 | 
228 | }
229 | 230 |

Property Map Traits

231 | 232 |

233 | Similar to the std::iterator_traits class of the STL, there 234 | is a boost::property_traits class that can be used to deduce 235 | the types associated with a property map type: the key and value 236 | types, and the property map category. There is a specialization 237 | of boost::property_traits so that pointers can be used as 238 | property map objects. In addition, the property map 239 | functions are overloaded for pointers. These traits classes and 240 | functions are defined in <boost/property_map/property_map.hpp>. 241 | 242 |

namespace boost {
243 | 
244 |   template <typename PropertyMap>
245 |   struct property_traits {
246 |      typedef typename PropertyMap::key_type key_type;
247 |      typedef typename PropertyMap::value_type value_type;
248 |      typedef typename PropertyMap::reference reference;
249 |      typedef typename PropertyMap::category category;
250 |   };
251 | 
252 | }
253 | 254 |

Property Map Types

255 | 256 | 298 | 299 |

History

300 | 301 | The property map interface originated as data accessors in 302 | Dietmar Kühl's Masters Thesis on generic graph algorithms. The 303 | property map idea also appeared under the guise of decorators 304 | in early versions of the Generic Graph Component Library (GGCL), which 305 | is now the Boost Graph Library (BGL). The main motivation for the 306 | property map interface was to support the access of data associated 307 | with vertices and edges in a graph, though the applicability of 308 | property maps goes beyond this. 309 | 310 |

Acknowledgments

311 | 312 | Thanks go to Dietmar Kühl for coming up with this mechanism, and 313 | thanks go to the Boost members who helped refine and improve the 314 | property map interface. Thanks to Dave Abrahams for managing the 315 | formal review of the BGL which included the property map library. 316 | 317 |

Notes to Implementors

318 | 319 | Copying a property map should be inexpensive since they are often 320 | passed by value. 321 | 322 |
323 |
324 | 325 | 326 |
Copyright © 2000-2002 327 | Jeremy Siek, Indiana University (jsiek@osl.iu.edu) 328 |
329 | 330 | 331 | 332 | 334 | 336 | 338 | 340 | 342 | -------------------------------------------------------------------------------- /doc/ref_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | Reference Property Map 12 | 14 | C++ Boost 16 | 17 |
18 | 19 |

20 |

21 |
 22 | template <typename KeyType, typename ValueType>
 23 | class ref_property_map
 24 | 
25 | 26 | This property map wraps a reference to some particular object, and 27 | returns that reference whenever a key object is input. 28 | 29 |

Where Defined

30 | 31 |

32 | boost/property_map/property_map.hpp 33 | 34 |

Model of

35 | 36 | Lvalue Property Map 37 | 38 |

Associated Types

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 52 | 53 | 54 | 55 | 58 | 61 | 62 | 63 | 64 | 67 | 70 | 71 | 72 |
TypeDescription
47 | boost::property_traits<ref_property_map>::value_type 48 | 50 | This type is the ValueType with which the template was instantiated. 51 |
56 | boost::property_traits<ref_property_map>::key_type 57 | 59 | This type is the KeyType with which the template was instantiated. 60 |
65 | boost::property_traits<ref_property_map>::category 66 | 68 | This type is boost::lvalue_property_map_tag. 69 |
73 | 74 |

Member Functions

75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 86 | 90 | 91 | 92 | 93 | 96 | 99 | 100 | 101 | 102 | 105 | 108 | 109 | 110 |
MemberDescription
84 | ref_property_map(ValueType& v) 85 | 87 | The constructor for ref_property_map is provided the reference that 88 | the property map will return when queried. 89 |
94 | ref_property_map(const ref_property_map& x) 95 | 97 | Copy constructor. 98 |
103 | ValueType& operator[](KeyType const&) const 104 | 106 | Returns the contained reference. 107 |
111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /doc/shared_array_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Shared Array Property Map 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | shared_array_property_map<ValueType, OffsetMap>
 23 | 
24 | 25 |

26 | This property map is an adaptor that contains a boost::shared_array and uses that 28 | array to store the property map's data. The resulting property map is a model 29 | of Lvalue Property Map. 30 | The OffsetMap type is responsible for converting 31 | key objects to integers that can be used as offsets into the array. 32 | 33 |

34 | 35 |

Where Defined

36 | 37 |

38 | boost/property_map/shared_array_property_map.hpp 39 | 40 |

41 |

Model Of

42 | 43 | Lvalue Property Map 44 | 45 |

46 | 47 |

Template Parameters

48 | 49 |

50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 69 | 70 | 71 |
ParameterDescriptionDefault
ValueTypeThe value type of the property map. 
OffsetMap Must be a model of Readable Property Map 67 | and the value type must be convertible to std::size_t. 68 |  
72 |

73 | 74 |

Members

75 | 76 |

77 | In addition to the methods and functions required by Lvalue Property Map, this 79 | class has the following members. 80 | 81 |


82 | 83 |
 84 | property_traits<shared_array_property_map>::value_type
 85 | 
86 | This is the same type as 87 | ValueType. 88 | 89 |
90 | 91 |
 92 | shared_array_property_map(size_t n)
 93 | 
94 | Constructor. Builds the property map with a size of n elements. The 95 | OffsetMap is default constructed. 96 | 97 |
98 | 99 |
100 | shared_array_property_map(size_t n, OffsetMap m)
101 | 
102 | Constructor. Builds the property map with a size of n elements. 103 | 104 |
105 | 106 |
107 | 108 |

Non-Member functions

109 | 110 |
111 | 112 |
113 |   template <class ValueType, class OffsetMap>
114 |   shared_array_property_map<ValueType, OffsetMap>
115 |   make_shared_array_property_map(size_t n, const ValueType&, OffsetMap omap)
116 | 
117 | A function for conveniently creating a shared array map. 118 | 119 | 120 |
121 | 122 |
123 |
124 | 125 | 126 |
Copyright © 2009 127 | Trustees of Indiana University. 128 |
129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /doc/static_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | Static Property Map 12 | 14 | C++ Boost 16 | 17 |
18 | 19 |

20 |

21 |
 22 | template <typename ValueType, typename KeyType = void>
 23 | class static_property_map
 24 | 
25 | 26 | This property map wraps a copy of some particular object, and 27 | returns a copy of that object whenever a key object is input. 28 | 29 |

Where Defined

30 | 31 |

32 | boost/property_map/property_map.hpp 33 | 34 |

Model of

35 | 36 | Readable Property Map 37 | 38 |

Associated Types

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 52 | 53 | 54 | 55 | 58 | 61 | 62 | 63 | 64 | 67 | 70 | 71 | 72 |
TypeDescription
47 | boost::property_traits<static_property_map>::value_type 48 | 50 | This type is the ValueType with which the template was instantiated. 51 |
56 | boost::property_traits<static_property_map>::key_type 57 | 59 | This type is the KeyType with which the template was instantiated. 60 |
65 | boost::property_traits<static_property_map>::category 66 | 68 | This type is boost::readable_property_map_tag. 69 |
73 | 74 |

Member Functions

75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 86 | 90 | 91 | 92 | 93 | 96 | 99 | 100 | 101 | 102 | 106 | 109 | 110 | 111 |
MemberDescription
84 | static_property_map(ValueType v) 85 | 87 | The constructor for static_property_map is provided the value that 88 | the property map will return when queried. 89 |
94 | static_property_map(const static_property_map& x) 95 | 97 | Copy constructor. 98 |
103 | template <typename T>
104 | ValueType& operator[](T) const
105 | 
107 | Returns the contained value by copy. 108 |
112 | 113 |

Non-Member Functions

114 | 115 | 116 | 121 | 122 | 123 |
117 | template <typename KeyType, typename ValueType>
118 | static_property_map<KeyType, ValueType>
119 | make_static_property_map(const ValueType& value);
120 | 
Returns a static_property_map with the given key type initialized to the given value.
124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /doc/transform_value_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Value-Transforming Property Map Adaptor 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | transform_value_property_map<UnaryFunction, PM, Ref>
 23 | 
24 | 25 |

26 | This property map is an adaptor that composes a function object after an existing property map. The new property map will model either Readable Property Map or a Lvalue Property Map. The category of the property map is based on whether the function's return type (as given by Ref) is a non-const reference type. 27 | 28 |

29 | 30 | 34 | 35 |

Where Defined

36 | 37 |

38 | boost/property_map/transform_value_property_map.hpp 39 | 40 |

41 |

Model Of

42 | 43 | Readable Property Map or Lvalue Property Map 44 | 45 |

46 | 47 |

Template Parameters

48 | 49 |

50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
ParameterDescriptionDefault
UnaryFunctionMust be a model of Unary Function that accepts an object of type property_traits<PM>::reference as an argument and returns a result of type Ref. 
PM The underlying property map. 65 |  
RefThe result type of the function.boost::result_of<const UnaryFunction(property_traits<PM>::reference)>::type
76 |

77 | 78 |

Members

79 | 80 |

81 | In addition to the methods and functions required by Readable Property Map or Lvalue Property Map, this 83 | class has the following members: 84 | 85 |


86 | 87 |
 88 | property_traits<transform_value_property_map>::value_type
 89 | 
90 | The type Ref with any reference or cv-qualifiers removed. 91 | 92 |
93 | 94 |
 95 | transform_value_property_map(const UnaryFunction& f, const PM& pm);
 96 | 
97 | Constructor. 98 | 99 |
100 | 101 |

Non-Member functions

102 | 103 |
104 | 105 |
106 |   template <class PM, class UnaryFunction>
107 |   transform_value_property_map<UnaryFunction, PM>
108 |   make_transform_value_property_map(const UnaryFunction& f, const PM& pm);
109 | 
110 | Returns a transform_value_property_map using the given function and property map type. 111 | 112 |
113 | 114 |
115 |   template <class Ref, class PM, class UnaryFunction>
116 |   transform_value_property_map<UnaryFunction, PM, Ref>
117 |   make_transform_value_property_map(const UnaryFunction& f, const PM& pm);
118 | 
119 | Returns a transform_value_property_map using the given function and property map, explicitly giving the function's result type. 120 | 121 |
122 | 123 |
124 |
125 | 126 | 127 |
Copyright © 2012Trustees of Indiana University 128 |
129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /doc/vector_property_map.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Vector Property Map 11 | 13 | C++ Boost 15 | 16 |
17 | 18 | 19 |

20 |

21 |
 22 | template<typename T, typename IndexMap = identity_property_map>
 23 | class vector_property_map;
 24 | 
25 | 26 |

27 | This property map is used to efficiently store properties for a variable 28 | number of elements. It's somewhere between associative_property_map and 30 | iterator_property_map. The latter 31 | is very fast, but requires that the number of stored elements is known 32 | when creating property map. The former does not have this requirement, but 33 | is slower, and requires stored elements to be comparable. 34 | 35 |

36 | The vector_property_map uses mapping from key to indices, 37 | and allows to add new elements. It accomplishes this by storing values 38 | in a vector, which is resized on demand. 39 | 40 |

41 | Note that vector_property_map does not provide reference/pointer 42 | stability for stored values. 43 | 44 |

Example

45 | 46 | example3.cpp: 47 | 48 |

49 |

 50 | #include <boost/property_map/vector_property_map.hpp>
 51 | #include <string>
 52 | #include <iostream>
 53 | 
 54 | int main()
 55 | {
 56 |     boost::vector_property_map<std::string> m;
 57 |     
 58 |     // Assign string to '4'. 
 59 |     m[4] = "e";
 60 |     std::cout << "'" << m[4] << "'\n";
 61 |     
 62 |     // Grab string from '10'. Since none is associated,
 63 |     // "" will be returned.
 64 |     std::cout << "'" << m[10] << "'\n";
 65 | }
 66 | 
67 | 68 |

Where Defined

69 | 70 |

71 | boost/property_map/vector_property_map.hpp 72 | 73 |

74 |

Model Of

75 | 76 | Lvalue Property Map 77 | 78 |

79 | 80 |

Template Parameters

81 | 82 |

83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 97 | 98 | 99 | 100 | 101 | 105 | 106 | 107 | 108 |
ParameterDescriptionDefault
TThe type of property value. Must be both Assignable 94 | and DefaultConstructible. 96 |  
IndexMap Must be a model of Readable Property Map 103 | and the value type must be convertible to 104 | std::vector<T>::size_type.identity_property_map
109 |

110 | 111 |

Members

112 | 113 |

114 | In addition to the methods and functions required by Lvalue Property Map, this 116 | class has the following members. 117 | 118 |


119 | 120 |
121 | vector_property_map(const IndexMap& index = IndexMap())
122 | 
123 | Constructor which takes an index map. 124 | 125 |
126 | 127 |
128 | vector_property_map(unsigned initial_size, const IndexMap& index = IndexMap())
129 | 
130 | This constructor version allows to specify maximum index of element 131 | that will be stored. Correct number will improve performance, but semantic 132 | is always the same. 133 | 134 |
135 | 136 |
137 | vector_property_map(const vector_property_map&)
138 | 
139 | Copy constructor. The copy will share the same data and changes 140 | made to it will affect original property map. 141 | 142 |
143 | 144 |
145 | vector_property_map& operator=(const vector_property_map&)
146 | 
147 | Assignment operator. The semantic is the same as for copy constructor. 148 | 149 |
150 | 151 |
152 | reference operator[](const key_type& v) const
153 | 
154 | The operator bracket for property access. 155 | 156 |
157 | 158 |
159 | std::vector<T>::iterator storage_begin()
160 | std::vector<T>::iterator storage_end()
161 | std::vector<T>::const_iterator storage_begin()
162 | std::vector<T>::const_iterator storage_end()
163 | 
164 | 165 |

This group of methods gives access to begin and end iterators of the 166 | underlying vector.

167 | 168 |

Rationale: The methods are handy, for example, when it's needed to 169 | specify a single value for all elements in a freshly created property map. The 170 | methods are not called simply "begin" and "end" since 171 | conceptually, vector_property_map is unbounded map, and has no end 172 | iterator. The direct access to the underlying method is not provided, since 173 | it would decrease encapsulation and make future performance tuning dangerous. 174 | 175 |

Acknolegements: Matthias Troyer suggested adding those functions. 176 | 177 |


178 | 179 |
180 | void reserve(unsigned size)
181 | 
182 | Reserve the space for storing elements with maximum index of 'size'. Unless 183 | element with greater index is accesses, all accesses will be take O(1) time. 184 | 185 | 186 |
187 | 188 |

Non-Member functions

189 | 190 |
191 | 192 |
193 | template
194 | vector_property_map
195 | make_vector_property_map(IndexMap index)
196 | {
197 |   return vector_property_map(index);
198 | } 
199 | 
200 | A function for conveniently creating a vector property map. 201 | 202 |
203 |
204 | 205 | 206 | 215 | 216 | 217 | 218 |
Copyright © 2002 207 | Jeremy Siek, 208 | Indiana University (jsiek@osl.iu.edu)
210 | Lie-Quan Lee, Indiana University (llee1@osl.iu.edu)
211 | Andrew Lumsdaine, 212 | Indiana University (lums@osl.iu.edu) 214 |
Copyright © 2003Vladimir Prus
219 | 220 | 221 | 222 | -------------------------------------------------------------------------------- /example/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost.PropertyMap Library example Jamfile 2 | # 3 | # Copyright (c) 2018 James E. King III 4 | # 5 | # Distributed under the Boost Software License, Version 1.0. (See accompany- 6 | # ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | import testing ; 9 | 10 | project : requirements /boost/property_map//boost_property_map ; 11 | 12 | test-suite "property_map-examples" 13 | : [ run compose_property_map_example.cpp ] 14 | [ run example1.cpp ] 15 | [ run example2.cpp ] 16 | [ run example3.cpp ] 17 | ; 18 | 19 | -------------------------------------------------------------------------------- /example/compose_property_map_example.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Eurodecision 2 | // Authors: Guillaume Pinot 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | 11 | int main() 12 | { 13 | const int idx[] = {2, 0, 4, 1, 3}; 14 | double v[] = {1., 3., 0., 4., 2.}; 15 | boost::compose_property_map cpm(v, idx); 16 | 17 | for (int i = 0; i < 5; ++i) 18 | std::cout << get(cpm, i) << " "; 19 | std::cout << std::endl; 20 | 21 | for (int i = 0; i < 5; ++i) 22 | ++cpm[i]; 23 | 24 | for (int i = 0; i < 5; ++i) 25 | std::cout << get(cpm, i) << " "; 26 | std::cout << std::endl; 27 | 28 | for (int i = 0; i < 5; ++i) 29 | put(cpm, i, 42.); 30 | 31 | for (int i = 0; i < 5; ++i) 32 | std::cout << get(cpm, i) << " "; 33 | std::cout << std::endl; 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /example/example1.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2002. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | template 13 | void foo(AddressMap address) 14 | { 15 | typedef typename boost::property_traits::value_type value_type; 16 | typedef typename boost::property_traits::key_type key_type; 17 | 18 | value_type old_address, new_address; 19 | key_type fred = "Fred"; 20 | old_address = get(address, fred); 21 | new_address = "384 Fitzpatrick Street"; 22 | put(address, fred, new_address); 23 | 24 | key_type joe = "Joe"; 25 | value_type& joes_address = address[joe]; 26 | joes_address = "325 Cushing Avenue"; 27 | } 28 | 29 | int 30 | main() 31 | { 32 | std::map name2address; 33 | boost::associative_property_map< std::map > 34 | address_map(name2address); 35 | 36 | name2address.insert(make_pair(std::string("Fred"), 37 | std::string("710 West 13th Street"))); 38 | name2address.insert(make_pair(std::string("Joe"), 39 | std::string("710 West 13th Street"))); 40 | 41 | foo(address_map); 42 | 43 | for (std::map::iterator i = name2address.begin(); 44 | i != name2address.end(); ++i) 45 | std::cout << i->first << ": " << i->second << "\n"; 46 | 47 | return EXIT_SUCCESS; 48 | } 49 | -------------------------------------------------------------------------------- /example/example2.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Ronald Garcia, Jeremy Siek 2002. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | template 13 | void display(ConstAddressMap address) 14 | { 15 | typedef typename boost::property_traits::value_type 16 | value_type; 17 | typedef typename boost::property_traits::key_type key_type; 18 | 19 | key_type fred = "Fred"; 20 | key_type joe = "Joe"; 21 | 22 | value_type freds_address = get(address, fred); 23 | value_type joes_address = get(address, joe); 24 | 25 | std::cout << fred << ": " << freds_address << "\n" 26 | << joe << ": " << joes_address << "\n"; 27 | } 28 | 29 | int 30 | main() 31 | { 32 | std::map name2address; 33 | boost::const_associative_property_map< std::map > 34 | address_map(name2address); 35 | 36 | name2address.insert(make_pair(std::string("Fred"), 37 | std::string("710 West 13th Street"))); 38 | name2address.insert(make_pair(std::string("Joe"), 39 | std::string("710 West 13th Street"))); 40 | 41 | display(address_map); 42 | 43 | return EXIT_SUCCESS; 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /example/example3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Vladimir Prus 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | int main() 11 | { 12 | boost::vector_property_map m; 13 | 14 | // Assign string to '4'. 15 | m[4] = "e"; 16 | std::cout << "'" << m[4] << "'\n"; 17 | 18 | // Grab string from '10'. Since none is associated, 19 | // "" will be returned. 20 | std::cout << "'" << m[10] << "'\n"; 21 | } 22 | -------------------------------------------------------------------------------- /include/boost/property_map/compose_property_map.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Eurodecision 2 | // Authors: Guillaume Pinot 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | // See http://www.boost.org/libs/property_map for documentation. 9 | 10 | #ifndef BOOST_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP 11 | #define BOOST_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP 12 | 13 | #include 14 | #include 15 | 16 | namespace boost { 17 | 18 | // A compose property map: make_compose_property_map(f, g)[x] == f[g[x]] 19 | // 20 | // g must be a readable property map. 21 | // The category of compose_property_map(f, g) is the category of f. 22 | 23 | template 24 | class compose_property_map 25 | { 26 | public: 27 | typedef typename boost::property_traits::category category; 28 | typedef typename boost::property_traits::key_type key_type; 29 | typedef typename boost::property_traits::value_type value_type; 30 | typedef typename boost::property_traits::reference reference; 31 | 32 | inline compose_property_map(const FPMap &f_p, const GPMap &g_p): 33 | f(f_p), g(g_p) 34 | {} 35 | 36 | inline compose_property_map() {} 37 | 38 | inline reference 39 | operator[](const key_type &v) const { 40 | return f[get(g, v)]; 41 | } 42 | 43 | // return type of get(): 44 | // if (reference is not a ref) 45 | // value_type 46 | // else if (reference is const) 47 | // reference 48 | // else 49 | // const value_type& 50 | inline friend typename boost::mpl::if_< 51 | boost::mpl::not_< boost::is_reference >, 52 | value_type, 53 | typename boost::mpl::if_< 54 | boost::is_const, 55 | reference, 56 | const value_type& 57 | >::type 58 | >::type 59 | get(const compose_property_map &m, const key_type &k) { 60 | return get(m.f, get(m.g, k)); 61 | } 62 | 63 | inline friend void 64 | put(const compose_property_map &m, const key_type &k, const value_type &v) { 65 | put(m.f, get(m.g, k), v); 66 | } 67 | 68 | private: 69 | FPMap f; 70 | GPMap g; 71 | }; 72 | 73 | template 74 | inline compose_property_map 75 | make_compose_property_map(const FPMap &f, const GPMap &g) { 76 | return compose_property_map(f, g); 77 | } 78 | 79 | } // namespace boost 80 | 81 | #endif // BOOST_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP 82 | -------------------------------------------------------------------------------- /include/boost/property_map/dynamic_property_map.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_PROPERTY_MAP_DYNAMIC_PROPERTY_MAP_HPP 2 | #define BOOST_PROPERTY_MAP_DYNAMIC_PROPERTY_MAP_HPP 3 | 4 | // Copyright 2004-5 The Trustees of Indiana University. 5 | 6 | // Use, modification and distribution is subject to the Boost Software 7 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | // dynamic_property_map.hpp - 11 | // Support for runtime-polymorphic property maps. This header is factored 12 | // out of Doug Gregor's routines for reading GraphML files for use in reading 13 | // GraphViz graph files. 14 | 15 | // Authors: Doug Gregor 16 | // Ronald Garcia 17 | // 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace boost { 39 | 40 | namespace detail { 41 | 42 | // read_value - 43 | // A wrapper around lexical_cast, which does not behave as 44 | // desired for std::string types. 45 | template 46 | inline Value read_value(const std::string& value) 47 | { return boost::lexical_cast(value); } 48 | 49 | template<> 50 | inline std::string read_value(const std::string& value) 51 | { return value; } 52 | 53 | } 54 | 55 | 56 | // dynamic_property_map - 57 | // This interface supports polymorphic manipulation of property maps. 58 | class dynamic_property_map 59 | { 60 | public: 61 | virtual ~dynamic_property_map() { } 62 | 63 | virtual boost::any get(const any& key) = 0; 64 | virtual std::string get_string(const any& key) = 0; 65 | virtual void put(const any& key, const any& value) = 0; 66 | virtual const std::type_info& key() const = 0; 67 | virtual const std::type_info& value() const = 0; 68 | }; 69 | 70 | 71 | ////////////////////////////////////////////////////////////////////// 72 | // Property map exceptions 73 | ////////////////////////////////////////////////////////////////////// 74 | 75 | struct dynamic_property_exception : public std::exception { 76 | ~dynamic_property_exception() throw() BOOST_OVERRIDE {} 77 | const char* what() const throw() BOOST_OVERRIDE = 0; 78 | }; 79 | 80 | struct property_not_found : public dynamic_property_exception { 81 | std::string property; 82 | mutable std::string statement; 83 | property_not_found(const std::string& property) : property(property) {} 84 | ~property_not_found() throw() BOOST_OVERRIDE {} 85 | 86 | const char* what() const throw() BOOST_OVERRIDE { 87 | if(statement.empty()) 88 | statement = 89 | std::string("Property not found: ") + property + "."; 90 | 91 | return statement.c_str(); 92 | } 93 | }; 94 | 95 | struct dynamic_get_failure : public dynamic_property_exception { 96 | std::string property; 97 | mutable std::string statement; 98 | dynamic_get_failure(const std::string& property) : property(property) {} 99 | ~dynamic_get_failure() throw() BOOST_OVERRIDE {} 100 | 101 | const char* what() const throw() BOOST_OVERRIDE { 102 | if(statement.empty()) 103 | statement = 104 | std::string( 105 | "dynamic property get cannot retrieve value for property: ") 106 | + property + "."; 107 | 108 | return statement.c_str(); 109 | } 110 | }; 111 | 112 | struct dynamic_const_put_error : public dynamic_property_exception { 113 | ~dynamic_const_put_error() throw() BOOST_OVERRIDE {} 114 | 115 | const char* what() const throw() BOOST_OVERRIDE { 116 | return "Attempt to put a value into a const property map: "; 117 | } 118 | }; 119 | 120 | 121 | namespace detail { 122 | 123 | // Trying to work around VC++ problem that seems to relate to having too many 124 | // functions named "get" 125 | template 126 | typename boost::property_traits::reference 127 | get_wrapper_xxx(const PMap& pmap, const Key& key) { 128 | using boost::get; 129 | return get(pmap, key); 130 | } 131 | 132 | // 133 | // dynamic_property_map_adaptor - 134 | // property-map adaptor to support runtime polymorphism. 135 | template 136 | class dynamic_property_map_adaptor : public dynamic_property_map 137 | { 138 | typedef typename property_traits::key_type key_type; 139 | typedef typename property_traits::value_type value_type; 140 | typedef typename property_traits::category category; 141 | 142 | // do_put - overloaded dispatches from the put() member function. 143 | // Attempts to "put" to a property map that does not model 144 | // WritablePropertyMap result in a runtime exception. 145 | 146 | // in_value must either hold an object of value_type or a string that 147 | // can be converted to value_type via iostreams. 148 | void do_put(const any& in_key, const any& in_value, mpl::bool_) 149 | { 150 | using boost::put; 151 | 152 | key_type key_ = any_cast(in_key); 153 | if (in_value.type() == boost::typeindex::type_id()) { 154 | put(property_map_, key_, any_cast(in_value)); 155 | } else { 156 | // if in_value is an empty string, put a default constructed value_type. 157 | std::string v = any_cast(in_value); 158 | if (v.empty()) { 159 | put(property_map_, key_, value_type()); 160 | } else { 161 | put(property_map_, key_, detail::read_value(v)); 162 | } 163 | } 164 | } 165 | 166 | void do_put(const any&, const any&, mpl::bool_) 167 | { 168 | BOOST_THROW_EXCEPTION(dynamic_const_put_error()); 169 | } 170 | 171 | public: 172 | explicit dynamic_property_map_adaptor(const PropertyMap& property_map_) 173 | : property_map_(property_map_) { } 174 | 175 | boost::any get(const any& key_) BOOST_OVERRIDE 176 | { 177 | return get_wrapper_xxx(property_map_, any_cast::key_type>(key_)); 178 | } 179 | 180 | std::string get_string(const any& key_) BOOST_OVERRIDE 181 | { 182 | std::ostringstream out; 183 | out << get_wrapper_xxx(property_map_, any_cast::key_type>(key_)); 184 | return out.str(); 185 | } 186 | 187 | void put(const any& in_key, const any& in_value) BOOST_OVERRIDE 188 | { 189 | do_put(in_key, in_value, 190 | mpl::bool_<(is_convertible::value)>()); 192 | } 193 | 194 | const std::type_info& key() const BOOST_OVERRIDE { return typeid(key_type); } 195 | const std::type_info& value() const BOOST_OVERRIDE { return typeid(value_type); } 196 | 197 | PropertyMap& base() { return property_map_; } 198 | const PropertyMap& base() const { return property_map_; } 199 | 200 | private: 201 | PropertyMap property_map_; 202 | }; 203 | 204 | } // namespace detail 205 | 206 | // 207 | // dynamic_properties - 208 | // container for dynamic property maps 209 | // 210 | struct dynamic_properties 211 | { 212 | typedef std::multimap > 213 | property_maps_type; 214 | typedef boost::function3, 215 | const std::string&, 216 | const boost::any&, 217 | const boost::any&> generate_fn_type; 218 | public: 219 | 220 | typedef property_maps_type::iterator iterator; 221 | typedef property_maps_type::const_iterator const_iterator; 222 | 223 | dynamic_properties() : generate_fn() { } 224 | dynamic_properties(const generate_fn_type& g) : generate_fn(g) {} 225 | 226 | ~dynamic_properties() {} 227 | 228 | template 229 | dynamic_properties& 230 | property(const std::string& name, PropertyMap property_map_) 231 | { 232 | boost::shared_ptr pm( 233 | boost::static_pointer_cast( 234 | boost::make_shared >(property_map_))); 235 | property_maps.insert(property_maps_type::value_type(name, pm)); 236 | 237 | return *this; 238 | } 239 | 240 | template 241 | dynamic_properties 242 | property(const std::string& name, PropertyMap property_map_) const 243 | { 244 | dynamic_properties result = *this; 245 | result.property(name, property_map_); 246 | return result; 247 | } 248 | 249 | iterator begin() { return property_maps.begin(); } 250 | const_iterator begin() const { return property_maps.begin(); } 251 | iterator end() { return property_maps.end(); } 252 | const_iterator end() const { return property_maps.end(); } 253 | 254 | iterator lower_bound(const std::string& name) 255 | { return property_maps.lower_bound(name); } 256 | 257 | const_iterator lower_bound(const std::string& name) const 258 | { return property_maps.lower_bound(name); } 259 | 260 | void 261 | insert(const std::string& name, boost::shared_ptr pm) 262 | { 263 | property_maps.insert(property_maps_type::value_type(name, pm)); 264 | } 265 | 266 | template 267 | boost::shared_ptr 268 | generate(const std::string& name, const Key& key, const Value& value) 269 | { 270 | if(!generate_fn) { 271 | BOOST_THROW_EXCEPTION(property_not_found(name)); 272 | } else { 273 | return generate_fn(name,key,value); 274 | } 275 | } 276 | 277 | private: 278 | property_maps_type property_maps; 279 | generate_fn_type generate_fn; 280 | }; 281 | 282 | template 283 | bool 284 | put(const std::string& name, dynamic_properties& dp, const Key& key, 285 | const Value& value) 286 | { 287 | for (dynamic_properties::iterator i = dp.lower_bound(name); 288 | i != dp.end() && i->first == name; ++i) { 289 | if (i->second->key() == typeid(key)) { 290 | i->second->put(key, value); 291 | return true; 292 | } 293 | } 294 | 295 | boost::shared_ptr new_map = dp.generate(name, key, value); 296 | if (new_map.get()) { 297 | new_map->put(key, value); 298 | dp.insert(name, new_map); 299 | return true; 300 | } else { 301 | return false; 302 | } 303 | } 304 | 305 | template 306 | Value 307 | get(const std::string& name, const dynamic_properties& dp, const Key& key) 308 | { 309 | for (dynamic_properties::const_iterator i = dp.lower_bound(name); 310 | i != dp.end() && i->first == name; ++i) { 311 | if (i->second->key() == typeid(key)) 312 | return any_cast(i->second->get(key)); 313 | } 314 | 315 | BOOST_THROW_EXCEPTION(dynamic_get_failure(name)); 316 | } 317 | 318 | template 319 | Value 320 | get(const std::string& name, const dynamic_properties& dp, const Key& key, type) 321 | { 322 | for (dynamic_properties::const_iterator i = dp.lower_bound(name); 323 | i != dp.end() && i->first == name; ++i) { 324 | if (i->second->key() == typeid(key)) 325 | return any_cast(i->second->get(key)); 326 | } 327 | 328 | BOOST_THROW_EXCEPTION(dynamic_get_failure(name)); 329 | } 330 | 331 | template 332 | std::string 333 | get(const std::string& name, const dynamic_properties& dp, const Key& key) 334 | { 335 | for (dynamic_properties::const_iterator i = dp.lower_bound(name); 336 | i != dp.end() && i->first == name; ++i) { 337 | if (i->second->key() == typeid(key)) 338 | return i->second->get_string(key); 339 | } 340 | 341 | BOOST_THROW_EXCEPTION(dynamic_get_failure(name)); 342 | } 343 | 344 | // The easy way to ignore properties. 345 | inline 346 | boost::shared_ptr 347 | ignore_other_properties(const std::string&, 348 | const boost::any&, 349 | const boost::any&) { 350 | return boost::shared_ptr(); 351 | } 352 | 353 | } // namespace boost 354 | 355 | #endif // BOOST_PROPERTY_MAP_DYNAMIC_PROPERTY_MAP_HPP 356 | -------------------------------------------------------------------------------- /include/boost/property_map/function_property_map.hpp: -------------------------------------------------------------------------------- 1 | // 2 | //======================================================================= 3 | // Author: Philipp Moeller 4 | // 5 | // Copyright 2012, Philipp Moeller 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See 8 | // accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | //======================================================================= 11 | // 12 | 13 | #ifndef BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP 14 | #define BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace boost { 25 | 26 | template::type> 27 | class function_property_map: public put_get_helper > { 28 | public: 29 | typedef Key key_type; 30 | typedef Ret reference; 31 | typedef typename boost::remove_cv::type>::type value_type; 32 | 33 | typedef typename boost::mpl::if_< 34 | boost::mpl::and_< 35 | boost::is_reference, 36 | boost::mpl::not_ > 37 | >, 38 | boost::lvalue_property_map_tag, 39 | boost::readable_property_map_tag>::type 40 | category; 41 | 42 | function_property_map(Func f = Func()) : f(f) {} 43 | 44 | reference operator[](const Key& k) const { 45 | return f(k); 46 | } 47 | 48 | private: 49 | Func f; 50 | }; 51 | 52 | template 53 | function_property_map 54 | make_function_property_map(const Func& f) { 55 | return function_property_map(f); 56 | } 57 | 58 | template 59 | function_property_map 60 | make_function_property_map(const Func& f) { 61 | return function_property_map(f); 62 | } 63 | 64 | } // boost 65 | 66 | #endif /* BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP */ 67 | -------------------------------------------------------------------------------- /include/boost/property_map/property_map.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 1999-2001. 2 | // Copyright (C) 2006 Trustees of Indiana University 3 | // Authors: Douglas Gregor and Jeremy Siek 4 | 5 | // Distributed under the Boost Software License, Version 1.0. (See 6 | // accompanying file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | // See http://www.boost.org/libs/property_map for documentation. 10 | 11 | #ifndef BOOST_PROPERTY_MAP_HPP 12 | #define BOOST_PROPERTY_MAP_HPP 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace boost { 30 | 31 | //========================================================================= 32 | // property_traits class 33 | 34 | BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type) 35 | BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) 36 | BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) 37 | BOOST_MPL_HAS_XXX_TRAIT_DEF(category) 38 | 39 | template 40 | struct is_property_map : 41 | boost::mpl::and_< 42 | has_key_type, 43 | has_value_type, 44 | has_reference, 45 | has_category 46 | > 47 | {}; 48 | 49 | template 50 | struct default_property_traits { 51 | typedef typename PA::key_type key_type; 52 | typedef typename PA::value_type value_type; 53 | typedef typename PA::reference reference; 54 | typedef typename PA::category category; 55 | }; 56 | 57 | struct null_property_traits {}; 58 | 59 | template 60 | struct property_traits : 61 | boost::mpl::if_, 62 | default_property_traits, 63 | null_property_traits>::type 64 | {}; 65 | 66 | #if 0 67 | template 68 | struct property_traits { 69 | typedef typename PA::key_type key_type; 70 | typedef typename PA::value_type value_type; 71 | typedef typename PA::reference reference; 72 | typedef typename PA::category category; 73 | }; 74 | #endif 75 | 76 | //========================================================================= 77 | // property_traits category tags 78 | 79 | namespace detail { 80 | enum ePropertyMapID { READABLE_PA, WRITABLE_PA, 81 | READ_WRITE_PA, LVALUE_PA, OP_BRACKET_PA, 82 | RAND_ACCESS_ITER_PA, LAST_PA }; 83 | } 84 | struct readable_property_map_tag { enum { id = detail::READABLE_PA }; }; 85 | struct writable_property_map_tag { enum { id = detail::WRITABLE_PA }; }; 86 | struct read_write_property_map_tag : 87 | public readable_property_map_tag, 88 | public writable_property_map_tag 89 | { enum { id = detail::READ_WRITE_PA }; }; 90 | 91 | struct lvalue_property_map_tag : public read_write_property_map_tag 92 | { enum { id = detail::LVALUE_PA }; }; 93 | 94 | //========================================================================= 95 | // property_traits specialization for pointers 96 | 97 | template 98 | struct property_traits { 99 | // BOOST_STATIC_ASSERT(boost::is_same::value && !"Using pointers as property maps is deprecated"); 100 | typedef T value_type; 101 | typedef value_type& reference; 102 | typedef std::ptrdiff_t key_type; 103 | typedef lvalue_property_map_tag category; 104 | }; 105 | template 106 | struct property_traits { 107 | // BOOST_STATIC_ASSERT(boost::is_same::value && !"Using pointers as property maps is deprecated"); 108 | typedef T value_type; 109 | typedef const value_type& reference; 110 | typedef std::ptrdiff_t key_type; 111 | typedef lvalue_property_map_tag category; 112 | }; 113 | 114 | #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) 115 | // MSVC doesn't have Koenig lookup, so the user has to 116 | // do boost::get() anyways, and the using clause 117 | // doesn't really work for MSVC. 118 | } // namespace boost 119 | #endif 120 | 121 | // These need to go in global namespace because Koenig 122 | // lookup does not apply to T*. 123 | 124 | // V must be convertible to T 125 | template 126 | inline void put(T* pa, std::ptrdiff_t k, const V& val) { pa[k] = val; } 127 | 128 | template 129 | inline const T& get(const T* pa, std::ptrdiff_t k) { return pa[k]; } 130 | 131 | #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) 132 | namespace boost { 133 | using ::put; 134 | using ::get; 135 | #endif 136 | 137 | //========================================================================= 138 | // concept checks for property maps 139 | 140 | template 141 | struct ReadablePropertyMapConcept 142 | { 143 | typedef typename property_traits::key_type key_type; 144 | typedef typename property_traits::reference reference; 145 | typedef typename property_traits::category Category; 146 | typedef boost::readable_property_map_tag ReadableTag; 147 | void constraints() { 148 | BOOST_CONCEPT_ASSERT((ConvertibleConcept)); 149 | 150 | val = get(pmap, k); 151 | } 152 | PMap pmap; 153 | Key k; 154 | typename property_traits::value_type val; 155 | }; 156 | template 157 | struct readable_property_map_archetype { 158 | typedef KeyArchetype key_type; 159 | typedef ValueArchetype value_type; 160 | typedef convertible_to_archetype reference; 161 | typedef readable_property_map_tag category; 162 | }; 163 | template 164 | const typename readable_property_map_archetype::reference& 165 | get(const readable_property_map_archetype&, 166 | const typename readable_property_map_archetype::key_type&) 167 | { 168 | typedef typename readable_property_map_archetype::reference R; 169 | return static_object::get(); 170 | } 171 | 172 | 173 | template 174 | struct WritablePropertyMapConcept 175 | { 176 | typedef typename property_traits::key_type key_type; 177 | typedef typename property_traits::category Category; 178 | typedef boost::writable_property_map_tag WritableTag; 179 | void constraints() { 180 | BOOST_CONCEPT_ASSERT((ConvertibleConcept)); 181 | put(pmap, k, val); 182 | } 183 | PMap pmap; 184 | Key k; 185 | typename property_traits::value_type val; 186 | }; 187 | template 188 | struct writable_property_map_archetype { 189 | typedef KeyArchetype key_type; 190 | typedef ValueArchetype value_type; 191 | typedef void reference; 192 | typedef writable_property_map_tag category; 193 | }; 194 | template 195 | void put(const writable_property_map_archetype&, 196 | const typename writable_property_map_archetype::key_type&, 197 | const typename writable_property_map_archetype::value_type&) { } 198 | 199 | 200 | template 201 | struct ReadWritePropertyMapConcept 202 | { 203 | typedef typename property_traits::category Category; 204 | typedef boost::read_write_property_map_tag ReadWriteTag; 205 | void constraints() { 206 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); 207 | BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept)); 208 | BOOST_CONCEPT_ASSERT((ConvertibleConcept)); 209 | } 210 | }; 211 | template 212 | struct read_write_property_map_archetype 213 | : public readable_property_map_archetype, 214 | public writable_property_map_archetype 215 | { 216 | typedef KeyArchetype key_type; 217 | typedef ValueArchetype value_type; 218 | typedef convertible_to_archetype reference; 219 | typedef read_write_property_map_tag category; 220 | }; 221 | 222 | 223 | template 224 | struct LvaluePropertyMapConcept 225 | { 226 | typedef typename property_traits::category Category; 227 | typedef boost::lvalue_property_map_tag LvalueTag; 228 | typedef typename property_traits::reference reference; 229 | 230 | void constraints() { 231 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); 232 | BOOST_CONCEPT_ASSERT((ConvertibleConcept)); 233 | 234 | typedef typename property_traits::value_type value_type; 235 | BOOST_MPL_ASSERT((boost::mpl::or_< 236 | boost::is_same, 237 | boost::is_same >)); 238 | 239 | reference ref = pmap[k]; 240 | ignore_unused_variable_warning(ref); 241 | } 242 | PMap pmap; 243 | Key k; 244 | }; 245 | template 246 | struct lvalue_property_map_archetype 247 | : public readable_property_map_archetype 248 | { 249 | typedef KeyArchetype key_type; 250 | typedef ValueArchetype value_type; 251 | typedef const ValueArchetype& reference; 252 | typedef lvalue_property_map_tag category; 253 | const value_type& operator[](const key_type&) const { 254 | return static_object::get(); 255 | } 256 | }; 257 | 258 | template 259 | struct Mutable_LvaluePropertyMapConcept 260 | { 261 | typedef typename property_traits::category Category; 262 | typedef boost::lvalue_property_map_tag LvalueTag; 263 | typedef typename property_traits::reference reference; 264 | void constraints() { 265 | BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); 266 | BOOST_CONCEPT_ASSERT((ConvertibleConcept)); 267 | 268 | typedef typename property_traits::value_type value_type; 269 | BOOST_MPL_ASSERT((boost::is_same)); 270 | 271 | reference ref = pmap[k]; 272 | ignore_unused_variable_warning(ref); 273 | } 274 | PMap pmap; 275 | Key k; 276 | }; 277 | template 278 | struct mutable_lvalue_property_map_archetype 279 | : public readable_property_map_archetype, 280 | public writable_property_map_archetype 281 | { 282 | typedef KeyArchetype key_type; 283 | typedef ValueArchetype value_type; 284 | typedef ValueArchetype& reference; 285 | typedef lvalue_property_map_tag category; 286 | value_type& operator[](const key_type&) const { 287 | return static_object::get(); 288 | } 289 | }; 290 | 291 | template 292 | struct typed_identity_property_map; 293 | 294 | // A helper class for constructing a property map 295 | // from a class that implements operator[] 296 | 297 | template 298 | struct put_get_helper { }; 299 | 300 | template 301 | inline Reference 302 | get(const put_get_helper& pa, const K& k) 303 | { 304 | Reference v = static_cast(pa)[k]; 305 | return v; 306 | } 307 | template 308 | inline void 309 | put(const put_get_helper& pa, K k, const V& v) 310 | { 311 | static_cast(pa)[k] = v; 312 | } 313 | 314 | //========================================================================= 315 | // Adapter to turn a RandomAccessIterator into a property map 316 | 317 | template ::value_type 323 | , class R = typename std::iterator_traits::reference 324 | #endif 325 | > 326 | class iterator_property_map 327 | : public boost::put_get_helper< R, 328 | iterator_property_map > 330 | { 331 | public: 332 | typedef typename property_traits::key_type key_type; 333 | typedef T value_type; 334 | typedef R reference; 335 | typedef boost::lvalue_property_map_tag category; 336 | 337 | inline iterator_property_map( 338 | RandomAccessIterator cc = RandomAccessIterator(), 339 | const IndexMap& _id = IndexMap() ) 340 | : iter(cc), index(_id) { } 341 | inline R operator[](key_type v) const { return *(iter + get(index, v)) ; } 342 | protected: 343 | RandomAccessIterator iter; 344 | IndexMap index; 345 | }; 346 | 347 | #if !defined BOOST_NO_STD_ITERATOR_TRAITS 348 | template 349 | inline iterator_property_map< 350 | RAIter, ID, 351 | typename std::iterator_traits::value_type, 352 | typename std::iterator_traits::reference> 353 | make_iterator_property_map(RAIter iter, ID id) { 354 | BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); 355 | typedef iterator_property_map< 356 | RAIter, ID, 357 | typename std::iterator_traits::value_type, 358 | typename std::iterator_traits::reference> PA; 359 | return PA(iter, id); 360 | } 361 | #endif 362 | template 363 | inline iterator_property_map 364 | make_iterator_property_map(RAIter iter, ID id, Value) { 365 | BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); 366 | typedef iterator_property_map PMap; 367 | return PMap(iter, id); 368 | } 369 | 370 | template ::value_type 376 | , class R = typename std::iterator_traits::reference 377 | #endif 378 | > 379 | class safe_iterator_property_map 380 | : public boost::put_get_helper< R, 381 | safe_iterator_property_map > 383 | { 384 | public: 385 | typedef typename property_traits::key_type key_type; 386 | typedef T value_type; 387 | typedef R reference; 388 | typedef boost::lvalue_property_map_tag category; 389 | 390 | inline safe_iterator_property_map( 391 | RandomAccessIterator first, 392 | std::size_t n_ = 0, 393 | const IndexMap& _id = IndexMap() ) 394 | : iter(first), n(n_), index(_id) { } 395 | inline safe_iterator_property_map() { } 396 | inline R operator[](key_type v) const { 397 | BOOST_ASSERT(get(index, v) < n); 398 | return *(iter + get(index, v)) ; 399 | } 400 | typename property_traits::value_type size() const { return n; } 401 | protected: 402 | RandomAccessIterator iter; 403 | typename property_traits::value_type n; 404 | IndexMap index; 405 | }; 406 | 407 | template 408 | inline safe_iterator_property_map< 409 | RAIter, ID, 410 | typename std::iterator_traits::value_type, 411 | typename std::iterator_traits::reference> 412 | make_safe_iterator_property_map(RAIter iter, std::size_t n, ID id) { 413 | BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); 414 | typedef safe_iterator_property_map< 415 | RAIter, ID, 416 | typename std::iterator_traits::value_type, 417 | typename std::iterator_traits::reference> PA; 418 | return PA(iter, n, id); 419 | } 420 | template 421 | inline safe_iterator_property_map 422 | make_safe_iterator_property_map(RAIter iter, std::size_t n, ID id, Value) { 423 | BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); 424 | typedef safe_iterator_property_map PMap; 425 | return PMap(iter, n, id); 426 | } 427 | 428 | //========================================================================= 429 | // An adaptor to turn a Unique Pair Associative Container like std::map or 430 | // std::hash_map into an Lvalue Property Map. 431 | 432 | template 433 | class associative_property_map 434 | : public boost::put_get_helper< 435 | typename UniquePairAssociativeContainer::value_type::second_type&, 436 | associative_property_map > 437 | { 438 | typedef UniquePairAssociativeContainer C; 439 | public: 440 | typedef typename C::key_type key_type; 441 | typedef typename C::value_type::second_type value_type; 442 | typedef value_type& reference; 443 | typedef lvalue_property_map_tag category; 444 | associative_property_map() : m_c(0) { } 445 | associative_property_map(C& c) : m_c(&c) { } 446 | reference operator[](const key_type& k) const { 447 | return (*m_c)[k]; 448 | } 449 | private: 450 | C* m_c; 451 | }; 452 | 453 | template 454 | associative_property_map 455 | make_assoc_property_map(UniquePairAssociativeContainer& c) 456 | { 457 | return associative_property_map(c); 458 | } 459 | 460 | template 461 | class const_associative_property_map 462 | : public boost::put_get_helper< 463 | const typename UniquePairAssociativeContainer::value_type::second_type&, 464 | const_associative_property_map > 465 | { 466 | typedef UniquePairAssociativeContainer C; 467 | public: 468 | typedef typename C::key_type key_type; 469 | typedef typename C::value_type::second_type value_type; 470 | typedef const value_type& reference; 471 | typedef lvalue_property_map_tag category; 472 | const_associative_property_map() : m_c(0) { } 473 | const_associative_property_map(const C& c) : m_c(&c) { } 474 | reference operator[](const key_type& k) const { 475 | return m_c->find(k)->second; 476 | } 477 | private: 478 | C const* m_c; 479 | }; 480 | 481 | template 482 | const_associative_property_map 483 | make_assoc_property_map(const UniquePairAssociativeContainer& c) 484 | { 485 | return const_associative_property_map(c); 486 | } 487 | 488 | //========================================================================= 489 | // A property map that always returns the same object by value. 490 | // 491 | template 492 | class static_property_map : 493 | public 494 | boost::put_get_helper > 495 | { 496 | ValueType value; 497 | public: 498 | typedef KeyType key_type; 499 | typedef ValueType value_type; 500 | typedef ValueType reference; 501 | typedef readable_property_map_tag category; 502 | static_property_map(ValueType v) : value(v) {} 503 | 504 | template 505 | inline reference operator[](T) const { return value; } 506 | }; 507 | 508 | template 509 | static_property_map 510 | make_static_property_map(const ValueType& v) { 511 | return static_property_map(v); 512 | } 513 | 514 | //========================================================================= 515 | // A property map that always returns a reference to the same object. 516 | // 517 | template 518 | class ref_property_map : 519 | public 520 | boost::put_get_helper > 521 | { 522 | ValueType* value; 523 | public: 524 | typedef KeyType key_type; 525 | typedef ValueType value_type; 526 | typedef ValueType& reference; 527 | typedef lvalue_property_map_tag category; 528 | ref_property_map(ValueType& v) : value(&v) {} 529 | ValueType& operator[](key_type const&) const { return *value; } 530 | }; 531 | 532 | //========================================================================= 533 | // A generalized identity property map 534 | template 535 | struct typed_identity_property_map 536 | : public boost::put_get_helper > 537 | { 538 | typedef T key_type; 539 | typedef T value_type; 540 | typedef T reference; 541 | typedef boost::readable_property_map_tag category; 542 | 543 | inline value_type operator[](const key_type& v) const { return v; } 544 | }; 545 | 546 | //========================================================================= 547 | // A property map that applies the identity function to integers 548 | typedef typed_identity_property_map identity_property_map; 549 | 550 | //========================================================================= 551 | // A property map that does not do anything, for 552 | // when you have to supply a property map, but don't need it. 553 | namespace detail { 554 | struct dummy_pmap_reference { 555 | template 556 | dummy_pmap_reference& operator=(const T&) { return *this; } 557 | operator int() { return 0; } 558 | }; 559 | } 560 | class dummy_property_map 561 | : public boost::put_get_helper 563 | { 564 | public: 565 | typedef void key_type; 566 | typedef int value_type; 567 | typedef detail::dummy_pmap_reference reference; 568 | typedef boost::read_write_property_map_tag category; 569 | inline dummy_property_map() : c(0) { } 570 | inline dummy_property_map(value_type cc) : c(cc) { } 571 | inline dummy_property_map(const dummy_property_map& x) 572 | : c(x.c) { } 573 | template 574 | inline reference operator[](Vertex) const { return reference(); } 575 | protected: 576 | value_type c; 577 | }; 578 | 579 | // Convert a Readable property map into a function object 580 | template 581 | class property_map_function { 582 | PropMap pm; 583 | typedef typename property_traits::key_type param_type; 584 | public: 585 | explicit property_map_function(const PropMap& pm): pm(pm) {} 586 | typedef typename property_traits::value_type result_type; 587 | result_type operator()(const param_type& k) const {return get(pm, k);} 588 | }; 589 | 590 | template 591 | property_map_function 592 | make_property_map_function(const PropMap& pm) { 593 | return property_map_function(pm); 594 | } 595 | 596 | } // namespace boost 597 | 598 | #include 599 | 600 | #endif /* BOOST_PROPERTY_MAP_HPP */ 601 | 602 | -------------------------------------------------------------------------------- /include/boost/property_map/property_map_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek, 2001. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // See http://www.boost.org/libs/property_map for documentation. 7 | 8 | #ifndef BOOST_PROPERTY_MAP_ITERATOR_HPP 9 | #define BOOST_PROPERTY_MAP_ITERATOR_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace boost { 17 | 18 | //====================================================================== 19 | // property iterator, generalized from ideas by Francois Faure 20 | 21 | namespace detail { 22 | 23 | template 24 | class lvalue_pmap_iter 25 | : public iterator_adaptor< lvalue_pmap_iter< Iterator, LvaluePropertyMap >, 26 | Iterator, 27 | typename property_traits::value_type, 28 | use_default, 29 | typename property_traits::reference> 30 | { 31 | friend class boost::iterator_core_access; 32 | 33 | typedef iterator_adaptor< lvalue_pmap_iter< Iterator, LvaluePropertyMap >, 34 | Iterator, 35 | typename property_traits::value_type, 36 | use_default, 37 | typename property_traits::reference> super_t; 38 | 39 | public: 40 | lvalue_pmap_iter() { } 41 | lvalue_pmap_iter(Iterator const& it, 42 | LvaluePropertyMap m) 43 | : super_t(it), 44 | m_map(m) {} 45 | 46 | private: 47 | typename super_t::reference 48 | dereference() const 49 | { 50 | return m_map[*(this->base_reference())]; 51 | } 52 | 53 | LvaluePropertyMap m_map; 54 | }; 55 | 56 | template 57 | class readable_pmap_iter : 58 | public iterator_adaptor< readable_pmap_iter< Iterator, ReadablePropertyMap >, 59 | Iterator, 60 | typename property_traits::value_type, 61 | use_default, 62 | typename property_traits::value_type> 63 | 64 | 65 | { 66 | friend class boost::iterator_core_access; 67 | 68 | typedef iterator_adaptor< readable_pmap_iter< Iterator, ReadablePropertyMap >, 69 | Iterator, 70 | typename property_traits::value_type, 71 | use_default, 72 | typename property_traits::value_type> super_t; 73 | 74 | public: 75 | readable_pmap_iter() { } 76 | readable_pmap_iter(Iterator const& it, 77 | ReadablePropertyMap m) 78 | : super_t(it), 79 | m_map(m) {} 80 | 81 | private: 82 | typename super_t::reference 83 | dereference() const 84 | { 85 | return get(m_map, *(this->base_reference())); 86 | } 87 | 88 | ReadablePropertyMap m_map; 89 | }; 90 | 91 | 92 | } // namespace detail 93 | 94 | template 95 | struct property_map_iterator_generator : 96 | mpl::if_< is_same< typename property_traits::category, lvalue_property_map_tag>, 97 | detail::lvalue_pmap_iter, 98 | detail::readable_pmap_iter > 99 | {}; 100 | 101 | template 102 | typename property_map_iterator_generator::type 103 | make_property_map_iterator(PropertyMap pmap, Iterator iter) 104 | { 105 | typedef typename property_map_iterator_generator::type Iter; 107 | return Iter(iter, pmap); 108 | } 109 | 110 | } // namespace boost 111 | 112 | #endif // BOOST_PROPERTY_MAP_ITERATOR_HPP 113 | 114 | -------------------------------------------------------------------------------- /include/boost/property_map/shared_array_property_map.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Trustees of Indiana University 2 | // Authors: Jeremiah Willcock, Andrew Lumsdaine 3 | 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | // See http://www.boost.org/libs/property_map for documentation. 9 | 10 | #ifndef BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP 11 | #define BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP 12 | 13 | #include 14 | #include 15 | 16 | namespace boost { 17 | 18 | template 19 | class shared_array_property_map 20 | : public boost::put_get_helper > 21 | { 22 | public: 23 | typedef typename property_traits::key_type key_type; 24 | typedef T value_type; 25 | typedef T& reference; 26 | typedef boost::lvalue_property_map_tag category; 27 | 28 | inline shared_array_property_map(): data(), index() {} 29 | 30 | explicit inline shared_array_property_map( 31 | size_t n, 32 | const IndexMap& _id = IndexMap()) 33 | : data(new T[n]), index(_id) {} 34 | 35 | inline T& operator[](key_type v) const { 36 | return data[get(index, v)]; 37 | } 38 | 39 | private: 40 | boost::shared_array data; 41 | IndexMap index; 42 | }; 43 | 44 | template 45 | shared_array_property_map 46 | make_shared_array_property_map(size_t n, const T&, const IndexMap& index) { 47 | return shared_array_property_map(n, index); 48 | } 49 | 50 | } // end namespace boost 51 | 52 | #endif // BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP 53 | -------------------------------------------------------------------------------- /include/boost/property_map/transform_value_property_map.hpp: -------------------------------------------------------------------------------- 1 | // 2 | //======================================================================= 3 | // Author: Philipp Moeller 4 | // 5 | // Copyright 2012, Philipp Moeller 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See 8 | // accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | //======================================================================= 11 | // 12 | 13 | #ifndef BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP 14 | #define BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace boost { 25 | 26 | template::reference)>::type> 27 | class transform_value_property_map: public put_get_helper > { 28 | public: 29 | typedef typename property_traits::key_type key_type; 30 | typedef Ret reference; 31 | typedef typename boost::remove_cv::type>::type value_type; 32 | 33 | typedef typename boost::mpl::if_< 34 | boost::mpl::and_< 35 | boost::is_reference, 36 | boost::mpl::not_ > 37 | >, 38 | boost::lvalue_property_map_tag, 39 | boost::readable_property_map_tag>::type 40 | category; 41 | 42 | transform_value_property_map(Func f, PM pm) : f(f), pm(pm) {} 43 | 44 | reference operator[](const key_type& k) const { 45 | return f(get(pm, k)); 46 | } 47 | 48 | private: 49 | Func f; 50 | PM pm; 51 | }; 52 | 53 | template 54 | transform_value_property_map 55 | make_transform_value_property_map(const Func& f, const PM& pm) { 56 | return transform_value_property_map(f, pm); 57 | } 58 | 59 | template 60 | transform_value_property_map 61 | make_transform_value_property_map(const Func& f, const PM& pm) { 62 | return transform_value_property_map(f, pm); 63 | } 64 | 65 | } // boost 66 | 67 | #endif /* BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP */ 68 | -------------------------------------------------------------------------------- /include/boost/property_map/vector_property_map.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) Vladimir Prus 2003. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | // 6 | // See http://www.boost.org/libs/graph/vector_property_map.html for 7 | // documentation. 8 | // 9 | 10 | #ifndef BOOST_PROPERTY_MAP_VECTOR_PROPERTY_MAP_HPP 11 | #define BOOST_PROPERTY_MAP_VECTOR_PROPERTY_MAP_HPP 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { 19 | template 20 | class vector_property_map 21 | : public boost::put_get_helper< 22 | typename std::iterator_traits< 23 | typename std::vector::iterator >::reference, 24 | vector_property_map > 25 | { 26 | public: 27 | typedef typename property_traits::key_type key_type; 28 | typedef T value_type; 29 | typedef typename std::iterator_traits< 30 | typename std::vector::iterator >::reference reference; 31 | typedef boost::lvalue_property_map_tag category; 32 | 33 | vector_property_map(const IndexMap& index = IndexMap()) 34 | : store(new std::vector()), index(index) 35 | {} 36 | 37 | vector_property_map(unsigned initial_size, 38 | const IndexMap& index = IndexMap()) 39 | : store(new std::vector(initial_size)), index(index) 40 | {} 41 | 42 | typename std::vector::iterator storage_begin() 43 | { 44 | return store->begin(); 45 | } 46 | 47 | typename std::vector::iterator storage_end() 48 | { 49 | return store->end(); 50 | } 51 | 52 | typename std::vector::const_iterator storage_begin() const 53 | { 54 | return store->begin(); 55 | } 56 | 57 | typename std::vector::const_iterator storage_end() const 58 | { 59 | return store->end(); 60 | } 61 | 62 | IndexMap& get_index_map() { return index; } 63 | const IndexMap& get_index_map() const { return index; } 64 | 65 | public: 66 | // Copy ctor absent, default semantics is OK. 67 | // Assignment operator absent, default semantics is OK. 68 | // CONSIDER: not sure that assignment to 'index' is correct. 69 | 70 | reference operator[](const key_type& v) const { 71 | typename property_traits::value_type i = get(index, v); 72 | if (static_cast(i) >= store->size()) { 73 | store->resize(i + 1, T()); 74 | } 75 | return (*store)[i]; 76 | } 77 | private: 78 | // Conceptually, we have a vector of infinite size. For practical 79 | // purposes, we start with an empty vector and grow it as needed. 80 | // Note that we cannot store pointer to vector here -- we cannot 81 | // store pointer to data, because if copy of property map resizes 82 | // the vector, the pointer to data will be invalidated. 83 | // I wonder if class 'pmap_ref' is simply needed. 84 | shared_ptr< std::vector > store; 85 | IndexMap index; 86 | }; 87 | 88 | template 89 | vector_property_map 90 | make_vector_property_map(IndexMap index) 91 | { 92 | return vector_property_map(index); 93 | } 94 | } 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Automatic redirection failed, please go to 7 | doc/property_map.html
8 |

© Copyright Beman Dawes, 2001

9 |

Distributed under the Boost Software License, Version 1.0. (See accompanying 10 | file LICENSE_1_0.txt or copy 11 | at www.boost.org/LICENSE_1_0.txt)

12 | 13 | 14 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "property_map", 3 | "name": "Property Map", 4 | "authors": [ 5 | "Jeremy Siek" 6 | ], 7 | "description": "Concepts defining interfaces which map key objects to value objects.", 8 | "category": [ 9 | "Containers", 10 | "Generic" 11 | ], 12 | "maintainers": [ 13 | "Douglas Gregor " 14 | ], 15 | "cxxstd": "11" 16 | } 17 | -------------------------------------------------------------------------------- /test/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # PropertyMap library 2 | 3 | # Copyright (C) 2005 Trustees of Indiana University 4 | # 5 | # Author: Douglas Gregor 6 | # 7 | # Use, modification and distribution is subject to the Boost Software License, 8 | # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 9 | # http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | # For more information, see http://www.boost.org/ 12 | 13 | import os ; 14 | 15 | project 16 | : requirements 17 | cygwin:_POSIX_C_SOURCE=201112L 18 | /boost/property_map//boost_property_map 19 | ; 20 | 21 | test-suite property_map 22 | : [ compile property_map_cc.cpp ] 23 | [ run compose_property_map_test.cpp ] 24 | [ run dynamic_properties_test.cpp ] 25 | [ run dynamic_properties_test.cpp : : : BOOST_NO_RTTI=1 : dynamic_properties_no_rtti_test ] 26 | [ run function_property_map_test.cpp ] 27 | [ run transform_value_property_map_test.cpp ] 28 | ; 29 | -------------------------------------------------------------------------------- /test/cmake_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2021-2024 Alexander Grund 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(cmake_subdir_test LANGUAGES CXX) 8 | 9 | # Those 2 should work the same 10 | # while using find_package for the installed Boost avoids the need to manually specify dependencies 11 | if(BOOST_CI_INSTALL_TEST) 12 | find_package(boost_property_map REQUIRED) 13 | else() 14 | set(BOOST_INCLUDE_LIBRARIES property_map) 15 | add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL) 16 | endif() 17 | 18 | add_executable(main main.cpp) 19 | target_link_libraries(main Boost::property_map) 20 | 21 | enable_testing() 22 | add_test(NAME main COMMAND main) 23 | -------------------------------------------------------------------------------- /test/cmake_test/main.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2002. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | template 13 | void foo(AddressMap address) 14 | { 15 | typedef typename boost::property_traits::value_type value_type; 16 | typedef typename boost::property_traits::key_type key_type; 17 | 18 | value_type old_address, new_address; 19 | key_type fred = "Fred"; 20 | old_address = get(address, fred); 21 | new_address = "384 Fitzpatrick Street"; 22 | put(address, fred, new_address); 23 | 24 | key_type joe = "Joe"; 25 | value_type& joes_address = address[joe]; 26 | joes_address = "325 Cushing Avenue"; 27 | } 28 | 29 | int 30 | main() 31 | { 32 | std::map name2address; 33 | boost::associative_property_map< std::map > 34 | address_map(name2address); 35 | 36 | name2address.insert(make_pair(std::string("Fred"), 37 | std::string("710 West 13th Street"))); 38 | name2address.insert(make_pair(std::string("Joe"), 39 | std::string("710 West 13th Street"))); 40 | 41 | foo(address_map); 42 | 43 | for (std::map::iterator i = name2address.begin(); 44 | i != name2address.end(); ++i) 45 | std::cout << i->first << ": " << i->second << "\n"; 46 | 47 | return EXIT_SUCCESS; 48 | } 49 | -------------------------------------------------------------------------------- /test/compose_property_map_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Eurodecision 2 | // Authors: Guillaume Pinot 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | void concept_checks() 14 | { 15 | using namespace boost; 16 | { 17 | typedef null_archetype<> Key; 18 | //typedef assignable_archetype > Value; 19 | typedef copy_constructible_archetype > Value; 20 | typedef readable_property_map_archetype GPMap; 21 | typedef readable_property_map_archetype FPMap; 22 | typedef compose_property_map CPM; 23 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); 24 | } 25 | { 26 | typedef null_archetype<> Key; 27 | typedef copy_constructible_archetype > Value; 28 | typedef readable_property_map_archetype GPMap; 29 | typedef writable_property_map_archetype FPMap; 30 | typedef compose_property_map CPM; 31 | BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept)); 32 | } 33 | { 34 | typedef null_archetype<> Key; 35 | typedef copy_constructible_archetype > Value; 36 | typedef readable_property_map_archetype GPMap; 37 | typedef read_write_property_map_archetype FPMap; 38 | typedef compose_property_map CPM; 39 | BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); 40 | } 41 | { 42 | typedef null_archetype<> Key; 43 | typedef copy_constructible_archetype > Value; 44 | typedef readable_property_map_archetype GPMap; 45 | typedef lvalue_property_map_archetype FPMap; 46 | typedef compose_property_map CPM; 47 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); 48 | } 49 | { 50 | typedef null_archetype<> Key; 51 | typedef copy_constructible_archetype > Value; 52 | typedef readable_property_map_archetype GPMap; 53 | typedef mutable_lvalue_property_map_archetype FPMap; 54 | typedef compose_property_map CPM; 55 | BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); 56 | } 57 | } 58 | 59 | void pointer_pmap_check() 60 | { 61 | const int idx[] = {2, 0, 4, 1, 3}; 62 | double v[] = {1., 3., 0., 4., 2.}; 63 | boost::compose_property_map cpm(v, idx); 64 | 65 | for (int i = 0; i < 5; ++i) { 66 | BOOST_TEST(get(cpm, i) == static_cast(i)); 67 | ++cpm[i]; 68 | BOOST_TEST(cpm[i] == static_cast(i + 1)); 69 | put(cpm, i, 42.); 70 | BOOST_TEST(cpm[i] == 42.); 71 | } 72 | } 73 | 74 | struct modulo_add_one { 75 | typedef int result_type; 76 | modulo_add_one(int m): modulo(m) {} 77 | int operator()(int i) const {return (i + 1) % modulo;} 78 | int modulo; 79 | }; 80 | 81 | void readable_pmap_checks() 82 | { 83 | using namespace boost; 84 | typedef function_property_map modulo_add_one_pmap; 85 | 86 | compose_property_map 87 | cpm(modulo_add_one(5), modulo_add_one(5)); 88 | 89 | for (int i = 0; i < 10; ++i) 90 | BOOST_TEST(get(cpm, i) == (i + 2) % 5); 91 | } 92 | 93 | int 94 | main() 95 | { 96 | concept_checks(); 97 | pointer_pmap_check(); 98 | readable_pmap_checks(); 99 | 100 | return boost::report_errors(); 101 | } 102 | -------------------------------------------------------------------------------- /test/dynamic_properties_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2005 The Trustees of Indiana University. 3 | 4 | // Use, modification and distribution is subject to the Boost Software 5 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | // 9 | // dynamic_properties_test.cpp - test cases for the dynamic property maps. 10 | // 11 | 12 | // Author: Ronald Garcia 13 | #include 14 | 15 | // For Borland, act like BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS is defined 16 | #if defined (BOOST_BORLANDC) && (BOOST_BORLANDC <= 0x570) && !defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) 17 | # define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS 18 | #endif 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // generate a dynamic_property_map that maps strings to strings 30 | // WARNING: This code leaks memory. For testing purposes only! 31 | // WARNING: This code uses library internals. For testing purposes only! 32 | boost::shared_ptr 33 | string2string_gen(const std::string&, 34 | const boost::any&, 35 | const boost::any&) { 36 | typedef std::map map_t; 37 | typedef 38 | boost::associative_property_map< std::map > 39 | property_t; 40 | 41 | 42 | map_t* mymap = new map_t(); // hint: leaky memory here! 43 | 44 | property_t property_map(*mymap); 45 | 46 | boost::shared_ptr pm( 47 | new 48 | boost::detail::dynamic_property_map_adaptor(property_map)); 49 | 50 | return pm; 51 | } 52 | 53 | 54 | int main() { 55 | 56 | // build property maps using associative_property_map 57 | 58 | std::map string2int; 59 | std::map double2string; 60 | boost::associative_property_map< std::map > 61 | int_map(string2int); 62 | boost::associative_property_map< std::map > 63 | dbl_map(double2string); 64 | 65 | 66 | // add key-value information 67 | string2int["one"] = 1; 68 | string2int["five"] = 5; 69 | 70 | double2string[5.3] = "five point three"; 71 | double2string[3.14] = "pi"; 72 | 73 | 74 | // build and populate dynamic interface 75 | boost::dynamic_properties properties; 76 | properties.property("int",int_map); 77 | properties.property("double",dbl_map); 78 | 79 | using boost::get; 80 | using boost::put; 81 | using boost::type; 82 | // Get tests 83 | { 84 | BOOST_TEST(get("int",properties,std::string("one")) == "1"); 85 | #ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS 86 | BOOST_TEST(boost::get("int",properties,std::string("one")) == 1); 87 | #endif 88 | BOOST_TEST(get("int",properties,std::string("one"), type()) == 1); 89 | BOOST_TEST(get("double",properties,5.3) == "five point three"); 90 | try { 91 | get("not_there",properties,""); 92 | BOOST_ERROR("No exception thrown."); 93 | } catch (boost::dynamic_get_failure& ex) { 94 | BOOST_TEST_CSTR_EQ(ex.what(), "dynamic property get cannot retrieve value for property: not_there."); 95 | // test idempotent error string generator branch 96 | BOOST_TEST_CSTR_EQ(ex.what(), "dynamic property get cannot retrieve value for property: not_there."); 97 | } 98 | } 99 | 100 | // Put tests 101 | { 102 | put("int",properties,std::string("five"),6); 103 | BOOST_TEST(get("int",properties,std::string("five")) == "6"); 104 | put("int",properties,std::string("five"),std::string("5")); 105 | #ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS 106 | BOOST_TEST(get("int",properties,std::string("five")) == 5); 107 | #endif 108 | BOOST_TEST(get("int",properties,std::string("five"),type()) == 5); 109 | put("double",properties,3.14,std::string("3.14159")); 110 | BOOST_TEST(get("double",properties,3.14) == "3.14159"); 111 | put("double",properties,3.14,std::string("pi")); 112 | #ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS 113 | BOOST_TEST(get("double",properties,3.14) == "pi"); 114 | #endif 115 | BOOST_TEST(get("double",properties,3.14,type()) == "pi"); 116 | } 117 | 118 | // Nonexistent property 119 | { 120 | try { 121 | get("nope",properties,3.14); 122 | BOOST_ERROR("No exception thrown."); 123 | } catch (boost::dynamic_get_failure&) { } 124 | 125 | try { 126 | put("nada",properties,3.14,std::string("3.14159")); 127 | BOOST_ERROR("No exception thrown."); 128 | } catch (boost::property_not_found& ex) { 129 | BOOST_TEST_CSTR_EQ(ex.what(), "Property not found: nada."); 130 | // test idempotent error string generator branch 131 | BOOST_TEST_CSTR_EQ(ex.what(), "Property not found: nada."); 132 | } 133 | } 134 | 135 | // Nonexistent property gets generated 136 | { 137 | boost::dynamic_properties props(&string2string_gen); 138 | put("nada",props,std::string("3.14"),std::string("pi")); 139 | BOOST_TEST(get("nada",props,std::string("3.14")) == "pi"); 140 | } 141 | 142 | // Use the ignore_other_properties generator 143 | { 144 | boost::dynamic_properties props(&boost::ignore_other_properties); 145 | bool value = put("nada",props,std::string("3.14"),std::string("pi")); 146 | BOOST_TEST(value == false); 147 | } 148 | 149 | return boost::report_errors(); 150 | } 151 | -------------------------------------------------------------------------------- /test/function_property_map_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | //======================================================================= 3 | // Author: Jeremiah Willcock 4 | // 5 | // Copyright 2012, Trustees of Indiana University 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See 8 | // accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | //======================================================================= 11 | // 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | template 20 | struct add1 {typedef T result_type; T operator()(const T& x) const {return x + 1;}}; 21 | 22 | template 23 | struct add1_val {typedef T result_type; T operator()(T x) const {return x + 1;}}; 24 | 25 | template 26 | struct return_fixed_ref { 27 | int* ptr; 28 | return_fixed_ref(int* ptr): ptr(ptr) {} 29 | typedef int& result_type; 30 | int& operator()(const T&) const {return *ptr;} 31 | }; 32 | 33 | int main() { 34 | using namespace boost; 35 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int>, int>)); 36 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int, double>, int>)); 37 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int>, int>)); 38 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int, double>, int>)); 39 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int>, int>)); 40 | BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept, int>, int>)); 41 | BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept, int>, int>)); 42 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept, int>, int>)); 43 | 44 | BOOST_STATIC_ASSERT((boost::is_same, int> >::category, boost::readable_property_map_tag>::value)); 45 | BOOST_STATIC_ASSERT((boost::is_same, int> >::category, boost::readable_property_map_tag>::value)); 46 | BOOST_STATIC_ASSERT((boost::is_same, int> >::category, boost::lvalue_property_map_tag>::value)); 47 | 48 | BOOST_TEST(get(function_property_map, int>(), 3) == 4); 49 | BOOST_TEST(get(function_property_map, int>(add1()), 4) == 5); 50 | BOOST_TEST(get(make_function_property_map(add1()), 5) == 6); 51 | BOOST_TEST(get(function_property_map, int>(), 3) == 4); 52 | BOOST_TEST(get(function_property_map, int>(add1_val()), 4) == 5); 53 | BOOST_TEST(get(make_function_property_map(add1_val()), 5) == 6); 54 | int val; 55 | const function_property_map, int> pm = return_fixed_ref((&val)); 56 | put(pm, 1, 6); 57 | BOOST_TEST(get(pm, 2) == 6); 58 | BOOST_TEST((get(pm, 3) = 7) == 7); 59 | BOOST_TEST(get(pm, 4) == 7); 60 | const function_property_map, int> pm2 = pm; // Check shallow copying 61 | BOOST_TEST(get(pm2, 5) == 7); 62 | put(pm2, 3, 1); 63 | BOOST_TEST(get(pm, 1) == 1); 64 | 65 | return boost::report_errors(); 66 | } 67 | -------------------------------------------------------------------------------- /test/property_map_cc.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2001. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // This file checks the property map concepts against the property map 11 | // archetypes to make sure they are consistent and that they compile. 12 | // This also checks all the property map classes defined in 13 | // property_map.hpp against the concept checking classes. 14 | 15 | int 16 | main() 17 | { 18 | using namespace boost; 19 | { 20 | typedef null_archetype<> Key; 21 | typedef assignable_archetype > Value; 22 | typedef readable_property_map_archetype PMap; 23 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); 24 | } 25 | { 26 | typedef null_archetype<> Key; 27 | typedef assignable_archetype > Value; 28 | typedef writable_property_map_archetype PMap; 29 | BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept)); 30 | } 31 | { 32 | typedef null_archetype<> Key; 33 | typedef assignable_archetype > Value; 34 | typedef read_write_property_map_archetype PMap; 35 | BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); 36 | } 37 | { 38 | typedef null_archetype<> Key; 39 | typedef assignable_archetype > Value; 40 | typedef lvalue_property_map_archetype PMap; 41 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); 42 | } 43 | { 44 | typedef null_archetype<> Key; 45 | typedef assignable_archetype > Value; 46 | typedef mutable_lvalue_property_map_archetype PMap; 47 | BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); 48 | } 49 | { 50 | typedef std::ptrdiff_t Key; 51 | typedef int* PMap; 52 | BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); 53 | } 54 | { 55 | typedef std::ptrdiff_t Key; 56 | typedef const int* PMap; 57 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); 58 | } 59 | { 60 | typedef sgi_assignable_archetype<> Key; // ? 61 | typedef sgi_assignable_archetype<> Value; 62 | typedef random_access_iterator_archetype Iterator; 63 | typedef readable_property_map_archetype IndexMap; 64 | typedef iterator_property_map PMap; 69 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); 70 | } 71 | { 72 | typedef sgi_assignable_archetype<> Key; 73 | typedef sgi_assignable_archetype<> Value; 74 | typedef mutable_random_access_iterator_archetype Iterator; 75 | typedef readable_property_map_archetype IndexMap; 76 | typedef iterator_property_map PMap; 81 | BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); 82 | } 83 | { 84 | typedef sgi_assignable_archetype< less_than_comparable_archetype<> > Key; 85 | typedef default_constructible_archetype< sgi_assignable_archetype<> > 86 | Value; 87 | typedef std::map Container; 88 | typedef associative_property_map PMap; 89 | BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); 90 | } 91 | { 92 | typedef sgi_assignable_archetype< less_than_comparable_archetype<> > Key; 93 | typedef default_constructible_archetype< sgi_assignable_archetype<> > 94 | Value; 95 | typedef std::map Container; 96 | typedef const_associative_property_map PMap; 97 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); 98 | } 99 | { 100 | typedef identity_property_map PMap; 101 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); 102 | } 103 | { 104 | typedef dummy_property_map PMap; 105 | BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); 106 | } 107 | { 108 | typedef sgi_assignable_archetype<> Key; // ? 109 | typedef sgi_assignable_archetype<> Value; 110 | typedef readable_property_map_archetype IndexMap; 111 | typedef shared_array_property_map PMap; 112 | BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); 113 | } 114 | return 0; 115 | } 116 | -------------------------------------------------------------------------------- /test/suppressions.txt: -------------------------------------------------------------------------------- 1 | leak:dynamic_properties_test 2 | leak:dynamic_properties_no_rtti_test 3 | -------------------------------------------------------------------------------- /test/transform_value_property_map_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | //======================================================================= 3 | // Author: Jeremiah Willcock 4 | // 5 | // Copyright 2012, Trustees of Indiana University 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See 8 | // accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | //======================================================================= 11 | // 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // Ensure this is not default constructible 21 | struct times2 {typedef int result_type; times2(int) {}; int operator()(int x) const {return 2 * x;}}; 22 | 23 | template 24 | struct add1 {typedef T result_type; T operator()(const T& x) const {return x + 1;}}; 25 | 26 | template 27 | struct add1_val {typedef T result_type; T operator()(T x) const {return x + 1;}}; 28 | 29 | template 30 | struct return_fixed_ref { 31 | int* ptr; 32 | return_fixed_ref(int* ptr): ptr(ptr) {} 33 | typedef int& result_type; 34 | int& operator()(const T&) const {return *ptr;} 35 | }; 36 | 37 | int main() { 38 | using namespace boost; 39 | typedef function_property_map PM; 40 | PM orig_pm(times2(0)); 41 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM>, int>)); 42 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM, double>, int>)); 43 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM>, int>)); 44 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM, double>, int>)); 45 | BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM>, int>)); 46 | BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept, PM>, int>)); 47 | BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept, PM>, int>)); 48 | BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept, PM>, int>)); 49 | 50 | BOOST_STATIC_ASSERT((boost::is_same, PM> >::category, boost::readable_property_map_tag>::value)); 51 | BOOST_STATIC_ASSERT((boost::is_same, PM> >::category, boost::readable_property_map_tag>::value)); 52 | BOOST_STATIC_ASSERT((boost::is_same, PM> >::category, boost::lvalue_property_map_tag>::value)); 53 | 54 | BOOST_TEST(get(transform_value_property_map, PM>(add1(), orig_pm), 3) == 7); 55 | BOOST_TEST(get(transform_value_property_map, PM>(add1(), orig_pm), 4) == 9); 56 | BOOST_TEST(get(make_transform_value_property_map(add1(), orig_pm), 5) == 11); 57 | BOOST_TEST(get(transform_value_property_map, PM>(add1_val(), orig_pm), 3) == 7); 58 | BOOST_TEST(get(transform_value_property_map, PM>(add1_val(), orig_pm), 4) == 9); 59 | BOOST_TEST(get(make_transform_value_property_map(add1_val(), orig_pm), 5) == 11); 60 | int val; 61 | const transform_value_property_map, PM> pm(return_fixed_ref((&val)), orig_pm); 62 | put(pm, 1, 6); 63 | BOOST_TEST(get(pm, 2) == 6); 64 | BOOST_TEST((get(pm, 3) = 7) == 7); 65 | BOOST_TEST(get(pm, 4) == 7); 66 | const transform_value_property_map, PM> pm2 = pm; // Check shallow copying 67 | BOOST_TEST(get(pm2, 5) == 7); 68 | put(pm2, 3, 1); 69 | BOOST_TEST(get(pm, 1) == 1); 70 | 71 | return boost::report_errors(); 72 | } 73 | --------------------------------------------------------------------------------