Let users specify a wrapping namespace.

This is useful when vwr is used and publicly exposed in a
library. If both the library and the standalone project depend
on vwr, this change gives the user the opportunity to keep the
two usages separate. This is especially important if both the
library and the standalone program happen to specialize the
Info template for the same type.
This commit is contained in:
King_DuckZ 2017-03-04 00:03:08 +00:00
parent aaa8e75dc1
commit db7b9becd5
9 changed files with 56 additions and 2 deletions

View File

@ -19,6 +19,10 @@
#include <cstddef> #include <cstddef>
#if defined VWR_OUTER_NAMESPACE
namespace VWR_OUTER_NAMESPACE {
#endif
namespace vwr { namespace vwr {
namespace bt { namespace bt {
template <typename T, T... I> template <typename T, T... I>
@ -50,4 +54,8 @@ namespace vwr {
} //namespace bt } //namespace bt
} //namespace vwr } //namespace vwr
#if defined VWR_OUTER_NAMESPACE
} //namespace VWR_OUTER_NAMESPACE
#endif
#endif #endif

View File

@ -22,6 +22,10 @@
# include <cstdint> # include <cstdint>
#endif #endif
#if defined VWR_OUTER_NAMESPACE
namespace VWR_OUTER_NAMESPACE {
#endif
namespace vwr { namespace vwr {
#if !defined(VWR_SIZE_TYPE) #if !defined(VWR_SIZE_TYPE)
typedef std::size_t size_type; typedef std::size_t size_type;
@ -30,4 +34,8 @@ namespace vwr {
#endif #endif
} //namespace vwr } //namespace vwr
#if defined VWR_OUTER_NAMESPACE
} //namespace VWR_OUTER_NAMESPACE
#endif
#endif #endif

View File

@ -21,6 +21,10 @@
#include "vectorwrapper/size_type.hpp" #include "vectorwrapper/size_type.hpp"
#include "vectorwrapper/vectorwrapper.hpp" #include "vectorwrapper/vectorwrapper.hpp"
#if defined VWR_OUTER_NAMESPACE
namespace VWR_OUTER_NAMESPACE {
#endif
namespace vwr { namespace vwr {
namespace implem { namespace implem {
template <typename TO, typename FROM, size_type... I> template <typename TO, typename FROM, size_type... I>
@ -43,4 +47,8 @@ namespace vwr {
} }
} //namespace vwr } //namespace vwr
#if defined VWR_OUTER_NAMESPACE
} //namespace VWR_OUTER_NAMESPACE
#endif
#endif #endif

View File

@ -22,6 +22,10 @@
#include <type_traits> #include <type_traits>
#include <cstddef> #include <cstddef>
#if defined VWR_OUTER_NAMESPACE
namespace VWR_OUTER_NAMESPACE {
#endif
namespace vwr { namespace vwr {
template <typename V1, typename V2, size_type S> template <typename V1, typename V2, size_type S>
typename std::common_type<typename Vec<V1>::scalar_type, typename Vec<V2>::scalar_type>::type dot ( const Vec<V1, S>& parLeft, const Vec<V2, S>& parRight ); typename std::common_type<typename Vec<V1>::scalar_type, typename Vec<V2>::scalar_type>::type dot ( const Vec<V1, S>& parLeft, const Vec<V2, S>& parRight );
@ -54,4 +58,8 @@ namespace vwr {
} }
} //namespace vwr } //namespace vwr
#if defined VWR_OUTER_NAMESPACE
} //namespace VWR_OUTER_NAMESPACE
#endif
#endif #endif

View File

@ -25,6 +25,10 @@
#include <array> #include <array>
#include <cassert> #include <cassert>
#if defined VWR_OUTER_NAMESPACE
namespace VWR_OUTER_NAMESPACE {
#endif
namespace vwr { namespace vwr {
template <typename V> template <typename V>
struct VectorWrapperInfo; struct VectorWrapperInfo;
@ -485,6 +489,10 @@ namespace vwr {
Vec<V> operator% ( const typename Vec<V>::scalar_type& parLeft, const Vec<V>& parRight ); Vec<V> operator% ( const typename Vec<V>::scalar_type& parLeft, const Vec<V>& parRight );
} //namespace vwr } //namespace vwr
#if defined VWR_OUTER_NAMESPACE
} //namespace VWR_OUTER_NAMESPACE
#endif
#include "vectorwrapper/vectorwrapper.inl" #include "vectorwrapper/vectorwrapper.inl"
#endif #endif

View File

@ -14,6 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#if defined VWR_OUTER_NAMESPACE
namespace VWR_OUTER_NAMESPACE {
#endif
namespace vwr { namespace vwr {
namespace implem { namespace implem {
template <typename T, bool=HasCastIgnoreTrailingPropertiesEnum<VectorWrapperInfo<T>>::value> struct IsCastIgnoreTrailingPropertiesSet; template <typename T, bool=HasCastIgnoreTrailingPropertiesEnum<VectorWrapperInfo<T>>::value> struct IsCastIgnoreTrailingPropertiesSet;
@ -611,3 +615,7 @@ namespace vwr {
); );
} }
} //namespace vwr } //namespace vwr
#if defined VWR_OUTER_NAMESPACE
} //namespace VWR_OUTER_NAMESPACE
#endif

View File

@ -22,3 +22,7 @@ add_test(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PROJECT_NAME} COMMAND ${PROJECT_NAME}
) )
target_compile_definitions(${PROJECT_NAME}
PRIVATE VWR_OUTER_NAMESPACE=vwr_outer_ns
)

View File

@ -15,6 +15,7 @@
} \ } \
} }
namespace vwr_outer_ns {
namespace vwr { namespace vwr {
SPECIALIZE_ARRAY_VECTOR(float, 2); SPECIALIZE_ARRAY_VECTOR(float, 2);
SPECIALIZE_ARRAY_VECTOR(float, 3); SPECIALIZE_ARRAY_VECTOR(float, 3);
@ -26,6 +27,7 @@ namespace vwr {
typedef Vec<std::array<short int, 2>> short2; typedef Vec<std::array<short int, 2>> short2;
typedef Vec<std::array<short int, 3>> short3; typedef Vec<std::array<short int, 3>> short3;
} //namespace vwr } //namespace vwr
} //namespace vwr_outer_ns
#undef SPECIALIZE_ARRAY_VECTOR #undef SPECIALIZE_ARRAY_VECTOR

View File

@ -3,7 +3,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
TEST(vwr, vector_cast) { TEST(vwr, vector_cast) {
using namespace vwr; using namespace vwr_outer_ns::vwr;
{ {
float2 v1(1.0f, 2.0f); float2 v1(1.0f, 2.0f);
@ -39,7 +39,7 @@ TEST(vwr, vector_cast) {
} }
TEST(vwr, promotion_static_cast) { TEST(vwr, promotion_static_cast) {
using namespace vwr; using namespace vwr_outer_ns::vwr;
{ {
short2 v1(100, 200); short2 v1(100, 200);