diff options
author | Josh Blum | 2013-03-21 20:11:08 -0700 |
---|---|---|
committer | Josh Blum | 2013-03-21 20:11:08 -0700 |
commit | 8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164 (patch) | |
tree | b808ee29d71270af7eedb50faa226f5eabb7ac18 /include/gras/detail/element.hpp | |
parent | 5485d42efba261c8879d1208c31d9cd5d18c303d (diff) | |
download | sandhi-8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164.tar.gz sandhi-8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164.tar.bz2 sandhi-8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164.zip |
gras: move element details into header
Diffstat (limited to 'include/gras/detail/element.hpp')
-rw-r--r-- | include/gras/detail/element.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/gras/detail/element.hpp b/include/gras/detail/element.hpp new file mode 100644 index 0000000..35033e1 --- /dev/null +++ b/include/gras/detail/element.hpp @@ -0,0 +1,27 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_DETAIL_ELEMENT_HPP +#define INCLUDED_GRAS_DETAIL_ELEMENT_HPP + +namespace gras +{ + template <typename T> + inline Element::Element(const boost::shared_ptr<T> &elem) + { + *this = elem->shared_to_element(); + } + + //! Convert a shared ptr of a derived class to an Element + inline Element &Element::shared_to_element(void) + { + try + { + this->weak_self = this->shared_from_this(); + } + catch(...){} + return *this; + } + +} //namespace gras + +#endif /*INCLUDED_GRAS_DETAIL_ELEMENT_HPP*/ |