/usr/include/boost/compute/types
Edit: /usr/include/boost/compute/types/pair.hpp (3177B)
//---------------------------------------------------------------------------//
// Copyright (c) 2013 Kyle Lutz
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_TYPES_PAIR_HPP
#define BOOST_COMPUTE_TYPES_PAIR_HPP
#include
#include
#include
#include
#include
#include
namespace boost {
namespace compute {
namespace detail {
// meta_kernel operator for std::pair literals
template
inline meta_kernel&
operator<<(meta_kernel &kernel, const std::pair &x)
{
kernel << "(" << type_name >() << ")"
<< "{" << kernel.make_lit(x.first) << ", "
<< kernel.make_lit(x.second) << "}";
return kernel;
}
// inject_type() specialization for std::pair
template
struct inject_type_impl >
{
void operator()(meta_kernel &kernel)
{
typedef std::pair pair_type;
kernel.inject_type();
kernel.inject_type();
kernel.add_type_declaration(type_definition());
}
};
// get() result type specialization for std::pair<>
template
struct get_result_type<0, std::pair >
{
typedef T1 type;
};
template
struct get_result_type<1, std::pair >
{
typedef T2 type;
};
// get() specialization for std::pair<>
template
inline meta_kernel& operator<<(meta_kernel &kernel,
const invoked_get > &expr)
{
kernel.inject_type >();
return kernel << expr.m_arg << (N == 0 ? ".first" : ".second");
}
} // end detail namespace
namespace detail {
// type_name() specialization for std::pair
template
struct type_name_trait >
{
static const char* value()
{
static std::string name =
std::string("_pair_") +
type_name() + "_" + type_name() +
"_t";
return name.c_str();
}
};
// type_definition() specialization for std::pair
template
struct type_definition_trait >
{
static std::string value()
{
typedef std::pair pair_type;
std::stringstream declaration;
declaration << "typedef struct {\n"
<< " " << type_name() << " first;\n"
<< " " << type_name() << " second;\n"
<< "} " << type_name() << ";\n";
return declaration.str();
}
};
} // end detail namespace
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_TYPES_PAIR_HPP