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:
parent
aaa8e75dc1
commit
db7b9becd5
9 changed files with 56 additions and 2 deletions
|
@ -19,6 +19,10 @@
|
|||
|
||||
#include <cstddef>
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
namespace VWR_OUTER_NAMESPACE {
|
||||
#endif
|
||||
|
||||
namespace vwr {
|
||||
namespace bt {
|
||||
template <typename T, T... I>
|
||||
|
@ -50,4 +54,8 @@ namespace vwr {
|
|||
} //namespace bt
|
||||
} //namespace vwr
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
} //namespace VWR_OUTER_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
# include <cstdint>
|
||||
#endif
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
namespace VWR_OUTER_NAMESPACE {
|
||||
#endif
|
||||
|
||||
namespace vwr {
|
||||
#if !defined(VWR_SIZE_TYPE)
|
||||
typedef std::size_t size_type;
|
||||
|
@ -30,4 +34,8 @@ namespace vwr {
|
|||
#endif
|
||||
} //namespace vwr
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
} //namespace VWR_OUTER_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "vectorwrapper/size_type.hpp"
|
||||
#include "vectorwrapper/vectorwrapper.hpp"
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
namespace VWR_OUTER_NAMESPACE {
|
||||
#endif
|
||||
|
||||
namespace vwr {
|
||||
namespace implem {
|
||||
template <typename TO, typename FROM, size_type... I>
|
||||
|
@ -43,4 +47,8 @@ namespace vwr {
|
|||
}
|
||||
} //namespace vwr
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
} //namespace VWR_OUTER_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
namespace VWR_OUTER_NAMESPACE {
|
||||
#endif
|
||||
|
||||
namespace vwr {
|
||||
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 );
|
||||
|
@ -54,4 +58,8 @@ namespace vwr {
|
|||
}
|
||||
} //namespace vwr
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
} //namespace VWR_OUTER_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
namespace VWR_OUTER_NAMESPACE {
|
||||
#endif
|
||||
|
||||
namespace vwr {
|
||||
template <typename V>
|
||||
struct VectorWrapperInfo;
|
||||
|
@ -485,6 +489,10 @@ namespace vwr {
|
|||
Vec<V> operator% ( const typename Vec<V>::scalar_type& parLeft, const Vec<V>& parRight );
|
||||
} //namespace vwr
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
} //namespace VWR_OUTER_NAMESPACE
|
||||
#endif
|
||||
|
||||
#include "vectorwrapper/vectorwrapper.inl"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
namespace VWR_OUTER_NAMESPACE {
|
||||
#endif
|
||||
|
||||
namespace vwr {
|
||||
namespace implem {
|
||||
template <typename T, bool=HasCastIgnoreTrailingPropertiesEnum<VectorWrapperInfo<T>>::value> struct IsCastIgnoreTrailingPropertiesSet;
|
||||
|
@ -611,3 +615,7 @@ namespace vwr {
|
|||
);
|
||||
}
|
||||
} //namespace vwr
|
||||
|
||||
#if defined VWR_OUTER_NAMESPACE
|
||||
} //namespace VWR_OUTER_NAMESPACE
|
||||
#endif
|
||||
|
|
|
@ -22,3 +22,7 @@ add_test(
|
|||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${PROJECT_NAME}
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE VWR_OUTER_NAMESPACE=vwr_outer_ns
|
||||
)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
} \
|
||||
}
|
||||
|
||||
namespace vwr_outer_ns {
|
||||
namespace vwr {
|
||||
SPECIALIZE_ARRAY_VECTOR(float, 2);
|
||||
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, 3>> short3;
|
||||
} //namespace vwr
|
||||
} //namespace vwr_outer_ns
|
||||
|
||||
#undef SPECIALIZE_ARRAY_VECTOR
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(vwr, vector_cast) {
|
||||
using namespace vwr;
|
||||
using namespace vwr_outer_ns::vwr;
|
||||
|
||||
{
|
||||
float2 v1(1.0f, 2.0f);
|
||||
|
@ -39,7 +39,7 @@ TEST(vwr, vector_cast) {
|
|||
}
|
||||
|
||||
TEST(vwr, promotion_static_cast) {
|
||||
using namespace vwr;
|
||||
using namespace vwr_outer_ns::vwr;
|
||||
|
||||
{
|
||||
short2 v1(100, 200);
|
||||
|
|
Loading…
Add table
Reference in a new issue