做房地产的地图仍然是必要的BGL? [英] Do property maps remain necessary for BGL?

查看:98
本文介绍了做房地产的地图仍然是必要的BGL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

宣布后的std ::地图<的std ::字符串,性病::字符串>中号是可能的:


  1. 写在地图: M [杰克] =323联盟圣;

  2. 从地图阅读:的std ::法院LT&;< M [杰克];

  1. Write to the map: M["Jack"] = "323 Union St";
  2. Read from the map: std::cout << M["Jack"];

和声明后,又的boost :: associative_property_map&LT;的std ::地图&LT;的std ::字符串,性病::字符串&GT;&GT; PM(M)我们是不是可以做更多的事情比:

And yet after declaring boost::associative_property_map<std::map<std::string, std::string>> PM(M) we are not able to do much more than:


  1. 写属性映射:的boost ::放(PM,弗雷德,323联盟圣);

  2. 从属性映射阅读:的boost ::得到(PM,弗雷德);

  1. Write to the property map: boost::put(PM, "Fred", "323 Union St");
  2. Read from the property map: boost::get(PM, "Fred");

您可以用属性映射,你已经不能做一个地图做什么?

What can you do with a property map that you cannot already do with a map?

上下文

考虑别人对他们来说,

#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300

是明显错误的。 IIUC,属性映射使用了如此沉重整个BGL 2098至02年,以消除需要编写MSVC一个库,另一个用于GCC。这个想法显然是,什么MSVC将处理,GCC会很乐意也处理。现在,MSVC处理C ++ 98,都是属性映射仍有必要或者他们只是遗物?的为什么的?

推荐答案

PropertyMaps 在很大程度上是一个接口抽象出来写,数据的读取,并通过隐藏实施的存储空间。

PropertyMaps are largely an interface to abstract away writing and reading of data and through that to hide the implementation of the storage.

您接口有时需要访问数据,你不希望强制类型的存储在您的用户使用。相反,你的某个时候提供数据存储,但要隐藏其实施。在这两种情况下,属性映射提供了一个很好的解决方案为其标准库的AssociativeSequence要求,是不是真的适合。

Your interface sometimes needs access to data and you don't want to force the kind of storage to use on your users. Inversely you sometime provide data storage but want to hide its implementation. In both cases property maps provide a nice solution for which the AssociativeSequence requirements of the standard library are not really suited.

这篇关于做房地产的地图仍然是必要的BGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆